Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need urgent help for clock divider

Status
Not open for further replies.

EDA_hg81

Advanced Member level 2
Joined
Nov 25, 2005
Messages
503
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
4,875
Code:
process ( iARM7_CLK  )
   begin
         if ( rising_edge( iARM7_CLK  ) ) then
                 spiclkcon <= spiclkcon + 1;
                 if ( spiclkcon = spiclk_gen ) then
                     spiclkcon <= x"00";
                     spiclk    <= not spiclk;
                 end if;
                 if ( iSD_INISTATUS(0) = '0' ) then      ******* when initialization is ok
                    if (  spiclkcon = spiclk_cap and  spiclk = '0' ) then 
                       case readstatus is
                          when x"00" =>
                              if (  sdread = '1' ) then
                                   datain1 <= x"FFFFFFFF";
                               readstatus  <= x"01";
                              end if;
                          when x"01" =>
                              outdata    <= datain1;  **** data is captured when situation "spiclkcon = spiclk_cap and  spiclk = '0'" is met
                              readstatus <= x"00";
                         when others => null;
                       end case;
                    else
                        outdata <= x"FFFF0000";      **** x"FFFF0000" is sent out when "spiclkcon = spiclk_cap and  spiclk = '0'" is not met
                    end if;
                elsif ( iSD_INISTATUS(0) = '1' ) then  **** when initialization is not finished readstatus back to x"00"
                   readstatus <= x"00";
               end if;
         end if;
end process;

This process is for reading SD card ID (such as x”260032”).

The problem is:

At the beginning, the output ID data can be read properly but when the SD card is taken out from slot, the output ID data still is x”260032” instead of x”FFFF0000”.

I decided the reason for above problem is that ID data is captured inside spiclk clock domain ( 2.5MHZ) which is generated by a clock divider and the “outdata” register can not be updated properly since “outdata” register is synchronized with iARM7_CLK (50MHZ).

I tried use:

else
outdata <= x"FFFF0000";

to fix above problem.

But this time ID outdata is always x”FFFF0000”.

I have used scope to verify the input data, the looks fine.

How I can fix this problem?

Thanks.
 

Zerox100

Full Member level 6
Joined
Mar 1, 2003
Messages
327
Helped
21
Reputation
42
Reaction score
10
Trophy points
1,298
Activity points
2,589
Try use
when others =>
outdata <= x"FFFF0000";

I guess it's the solution!
 

    EDA_hg81

    Points: 2
    Helpful Answer Positive Rating

EDA_hg81

Advanced Member level 2
Joined
Nov 25, 2005
Messages
503
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
4,875
I will try and let you know the result.
 

EDA_hg81

Advanced Member level 2
Joined
Nov 25, 2005
Messages
503
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
4,875
and I have to show the SD card ID on the shell.

Do you think the shell is the problem?
 

blueroomelectronics

Advanced Member level 5
Joined
Sep 17, 2006
Messages
1,681
Helped
180
Reputation
358
Reaction score
77
Trophy points
1,328
Location
Toronto, Canada
Activity points
8,696
Question for EDA_hg81, how come you expect help from others but in your 3 years and 245 posts you've offered none?
 

aafaq

Newbie level 4
Joined
Feb 25, 2008
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,309
U can use DCM (Digital Clock Manager) n get the desire clock
 

Zerox100

Full Member level 6
Joined
Mar 1, 2003
Messages
327
Helped
21
Reputation
42
Reaction score
10
Trophy points
1,298
Activity points
2,589
You should test your shell befor start to design hardware. for example design a counter and send value counter to shell and test it ...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top