Please Help (microSD card and SPI - MC9s08GT32

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Please Help (microSD card and SPI - MC9s08GT32

4,887 次查看
juanb_arg
Contributor I
Hi guys, I am working with a microSD card in SPI mode. The cpu is a gt32
I can`t enter in spi mode, I do not see any response from the card,. I have done a little piece of code that sends CMD0 and whait for the R1 response (0x01 card in idle state) but it never comes.
I think the code is ok, maybe is hardware problem, I have tested the connection and is ok. I didnt put any pullup or pull down resistors. I dont know what  to do! please help me!
The attached file is the code, if someone could check it, it would help me a lot.
Thanks,
Juan 
 
 
 
 
Added p/n to subject.



Message Edited by NLFSJ on 2008-10-06 07:02 AM

Send_CMD_0.txt

Message Edited by t.dowe on 2009-09-04 02:01 PM
标签 (1)
0 项奖励
回复
8 回复数

1,094 次查看
erooll
Contributor II
Hi Juan, try to do this: set bits CPOL and CPHA of SPI1C1 control register, and be sure that you has set PTED_PTED2 as output (PTEDD_PTEDD2 = 1), this doesn't appears in your code.
 I also work with a SD and this is the only strange setting that I need set to comunicate with SD card, this setting was implemented in HC08GP32, GT60 and recently in a QE128 and works fine the rest of code looks good.

Good Luck.


Message Edited by erooll on 2008-10-05 10:59 PM

Message Edited by erooll on 2008-10-05 11:02 PM
0 项奖励
回复

1,094 次查看
juanb_arg
Contributor I
Hi eroll! First of all thanks for your answer. Well i have taken what you said about clock considerations and port e into account in my code.
 Yesterday i while was testing the code and i found that in one situation it worked well, and later i tried to repeat the test and it did not work again. Iam using a BDM open source debugguer. i dont know if it is working as it should...sometimes when i debug a character sending it shows me the contents of the spi registers and sometimes not , it is so extrange... could be a problem of the debbuguer?
thaks again
regars
juan
0 项奖励
回复

1,094 次查看
bigmac
Specialist III
Hello Juan,
 
If you are attempting to single step through the SPI communication code, keep in mind that it is possible for the actions of the debugger to clear the SPRF flag before the code can determine that it has become set.  It is best not to single step, but use a break point after the return data has been read.
 
Regards,
Mac
 
0 项奖励
回复

1,094 次查看
juanb_arg
Contributor I

Hi! Thanks Jim and BigMac for your response.

BigMac, what you told me is right, I have experimented it.  after that I always put the breakpoints after the call of the spi send or receive.

The problem that I was trying to describe, (maybe I didn’t explained it so clearly,  English is my second language :smileysad:) is that when i start the debugging sometimes i can see the spi working well, the SPI1D reg is full after sending a character in the breakpoint, and after that i restart the debugging and it doesn’t have the same behavior , and the program is exactly the same.

I dont know why....

 

0 项奖励
回复

1,094 次查看
JimDon
Senior Contributor III

That's why I mentioned the pull up. If there is not a pull up on the data line from the card to the MCU, when you reset the card, it may float low you will not see FF like you expect.



0 项奖励
回复

1,094 次查看
saranezhil30
Contributor I

Hi, I Got the low signal (500mv) at Data out from SD Card, even pull up does not work. Is it card problem?

 

Thank you

 

 

0 项奖励
回复

1,094 次查看
JimDon
Senior Contributor III
You DO need at least a pull-up on the data out line.
If you read the spec it shows the values you should have.
0 项奖励
回复

1,094 次查看
Superberti
Contributor I
 Hi,

JimDon wrote:
You DO need at least a pull-up on the data out line.
If you read the spec it shows the values you should have.

Is it possible to use the MCU internal pull-up even though the pin is defined as hardware SPI MISO?

I don't see something like that in the processor expert...

 

Thanks and bye,

0 项奖励
回复