Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

interface ADC0804 with CPLD

Hello Folks,

I am trying to interface the ADC0804, 8-bit output to 8 input pins of a CPLD. I intend to provide 1MHz clock frequency to the ADC and use a system clock for the CPLD at a lower frequency say 500 kHz. The reasoning bieng the ADC will have plenty of time to change its value within a system clock cycle. I have looked at the control steps for the ADC and have attempted to initiate a start conversion cycle. Could someone please let me know if I am going about this correctly. Thank you in advance. The code is not complete as it does not read the value yet. I have to convert the crystal frequency of 25MHz into a squarewave in code.

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    That... will not work.

    What you have can be summarized as (in a cleaner way)

    clk_out <= not clk_in;
    process(clk_out)
    begin
    if(clk_out'event and clk_out='1') then
        count <=count+1;
        if(count = 5) then
            clk <= not clk;
            count <= 1;
    --        cs <= '0'; -- overriden
    --        wr<='0';  -- overriden
            wr<='0';
            cs<='1';
            if(intr = '0') then
                flag <= '1';
            end if;
        end if;
    end if;
    end process;

    Don't abuse "buffer". Use "in", "out" and "inout" as needed.

    You mention that you want 1 MHz for the ADC and 500 kHz for the CPLD, but in your code, logic is running in the (negated) input clock, not in the divided by 2 "clk".
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thank you very much for your advice, I have tried to correct the mistakes. Could you please have a quick look at this version.:)