Discussion in "8051 Discussion Forum" started by    duncan    Aug 3, 2008.
Mon Sep 08 2008, 12:45 pm
#21
i m sorry,Ajay..but i m still very confuse how to calculate the SPI clock frequency

SPI clock frequency = baud rate?

according to the data sheet,

baudrate = Fclk periph / baud rate divisor

Fclk periph = Fosc/[4*(255-CKRL)]

do we need to set the CKRL?
Tue Sep 09 2008, 03:05 am
#22
as i said, you can use clock of 1Mhz or closer for initialization of MMC.
Clock frequency is selected by setting SPR bits in SPCON register.
open datasheet and check table 46 on page 65.
there you can see different combination of SPR bits gives you different clock frequency.

lets say your crystal is running at 12Mhz and you want a clock near by 1Mhz. Now at reset state CKRL is set to FFh, so Fclk periph will be Fosc/2 (page 16 of datasheet).
so now internal peripheral clock is running at 6Mhz. Now as per page 65 of datasheet, to have 1Mhz clock or closer one.. i can select BD as 4 or 8

if BD is 8 then SPI clock is
6/8 = 0.75Mhz
if BD is 4 then SPI clock is
6/4 = 1.5Mhz

both will work got it now?
Tue Sep 09 2008, 01:43 pm
#23
thx alot
Wed Sep 10 2008, 08:39 pm
#24
Does anyone has any way to display CID detail in the LCD??
Thu Sep 11 2008, 02:21 am
#25
read CID register, convert the number to corresponding ascii and display on LCD.

you can try this kind of code to display a hex value on LCD
void send_lcdnum(unsigned char num){
     unsigned char temp;
     temp = (num>
>
4) & 0x0F;
     if(temp<10)
          sendchar_lcd(temp+0x30);
     else
          sendchar_lcd(temp-10+0x41);

     temp = num & 0x0F;
     if(temp<10)
          sendchar_lcd(temp+0x30);
     else
          sendchar_lcd(temp-10+0x41);
}
Thu Sep 11 2008, 02:06 pm
#26
hi ajay, i already try a lot of method but i still couldnt initialize my sd card.....

then i try to send 0xff to the sd card, after i turn on the sd card, i couldnt get 0xff..

from the timing diagram u had provide, the data out from sd card is always high b4 we send any command...

does this shows that there is problem with my hard ware?

Fri Sep 12 2008, 01:07 am
#27
well, its like this..
as your data out from SD is high means you are getting FF in program. you will keep on reading till you get the desired response.
like when you send CMD0 you keep on reading from SD till you get 0x01 from card, till that time your data out pin will remain high and data received will be 0xFF.
Fri Sep 12 2008, 10:17 am
#28
for(i=0;i<100;i++)
      {
      	if(status != 0xFF) 
				break;
      	status = SPI_transmit(0xFF);	//pump in dummy data to get the response
      }


this is the code that i write to get my response from sd card..but before i get my response, the data out line do not remain high, the loop break before i get the desired result..
my data out line is stable at high state, does this means that my there is problem with my hardware?


[ Edited Fri Sep 12 2008, 10:18 am ]
Fri Sep 12 2008, 01:57 pm
#29
in order to print 4 hex number on lcd, is it like this?
void send_lcdnum(unsigned char num){
unsigned char temp;
temp = (num>>16) & 0x0F;
if(temp<10)
sendchar_lcd(temp+0x30);
else
sendchar_lcd(temp-10+0x41);
temp = (num>>8) & 0x0F;
if(temp<10)
sendchar_lcd(temp+0x30);
else
sendchar_lcd(temp-10+0x41);
temp = (num>>4) & 0x0F;
if(temp<10)
sendchar_lcd(temp+0x30);
else
sendchar_lcd(temp-10+0x41);

temp = num & 0x0F;
if(temp<10)
sendchar_lcd(temp+0x30);
else
sendchar_lcd(temp-10+0x41);
}
Sat Sep 13 2008, 12:06 am
#30
no you cannot say its hardware problem, it could be possible that your program is not working properly, try checking the clock pin on oscilloscope and see if its working or not..

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am