Sign in to follow this  
hamster

Using PMODmic3 with PMODamp3.

Recommended Posts

I got a bit bored yesterday, and hooked the PMODmic3 up to my PMODamp3 design, and put a small delay (of 32768 samples).

The VHDL module for the microphone interface is actually surprisingly small :

----------------------------------------------------------------------------------
-- Engineer: Mike Field <hamster@snap.net.nz>
-- 
-- Module Name: pmod_mic3 - Behavioral
--
-- Description: Sample input form a PMOD_MIC3, once every 256 ticks of the
--              master clock (mclk). 
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity pmod_mic3 is
    Port ( mclk   : in  STD_LOGIC;
           sclk   : out STD_LOGIC;
           cs     : out STD_LOGIC;
           sdat   : in  STD_LOGIC;
           de     : out STD_LOGIC;
           sample : out STD_LOGIC_VECTOR (15 downto 0) := (others => '0'));
end pmod_mic3;
architecture Behavioral of pmod_mic3 is
    signal counter : unsigned(7 downto 0)          := (others => '0');
    signal data_sr : std_logic_vector(11 downto 0) := (others => '0');
begin
process(mclk) 
    begin
        if rising_edge(mclk) then
            de <= '0';
            if counter > 5 and counter < 6 + 16*8 then
                cs <= '0';
            else
                cs <= '1';
            end if;
            if counter(2 downto 0) = 0 then
                data_sr  <= data_sr(10 downto 0) & sdat; 
            end if;
            if counter = 17 * 8 then
                ---------------------------------------------
                -- convert the 12-bit unsigned sample to the
                -- lowest 12 bits of a 16-bit signed sample
                -- by adding it to -2048 
                ---------------------------------------------
                de <= '1';
                sample <= std_logic_vector(to_unsigned(63488,16) + unsigned(data_sr)); 
            end if;
            sclk <= std_logic(counter(2));
            counter <= counter + 1;
        end if;
    end process;
 
end Behavioral;

If interested, the rest of the code is at http://hamsterworks.co.nz/mediawiki/index.php/MIC_and_AMP

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this