[En-Nut-Discussion] Failed to mount sdcard using at91sam7x-ek.conf, fails to write to SPI
Adeel Ahmed Nafis
adeel at linkwisetech.com
Fri Apr 12 16:27:32 CEST 2013
Hi,
running into problems again. Have downloaded and built the
ethernut-5.1.0 on linux, and have been able to program it. Tested out
the sample app 'httpd' in app/httpd, using PHAT.
It hangs on MmCardReset() in nut/dev/mmcard.c line 1206
for (i = 0; i < 10; i++) {
(*ifc->mmcifc_io) (0xFF); //hangs in this routine
}
ifc->mmcifc_io points to At91SpiMmCard0Io() in
nut/arch/arm/dev/atmel/spimmc_at91.c
After writing it seems that SPI_RDRF is not set
outr(MMC_SPI_TDR, val);
/* Wait for receiver data register full. */
while((inr(MMC_SPI_SR) & SPI_RDRF) == 0); //hangs on this line, never returns
Did not get time to scope it yet.
While trying out different things, I came across this in
At91SpiMmcIfcInit() nut/arch/arm/dev/atmel/spimmc_at91.c
/* Set SPI to master mode, fixed peripheral at CS1, fault detection disabled. */
outr(MMC_SPI_MR, (1 << SPI_PCS_LSB) | SPI_MODFDIS | SPI_MSTR);
As we are using CS0 should not this be the following? Or does it not matter.
outr(MMC_SPI_MR, (0x0E << SPI_PCS_LSB) | SPI_MODFDIS | SPI_MSTR);
From the datasheet pp:269
PCS: Peripheral Chip Select
This field is only used if Fixed Peripheral Select is active (PS = 0).
If PCSDEC = 0:
PCS = xxx0 NPCS[3:0] = 1110
PCS = xx01 NPCS[3:0] = 1101
PCS = x011 NPCS[3:0] = 1011
PCS = 0111 NPCS[3:0] = 0111
PCS = 1111 forbidden (no peripheral is selected)
In our case PS = 0 and PCSDEC = 0.
Any case, both PCS=1, and PCS=0x0E have no effect, on the outcome.
--
Adeel Nafis
Design Engineer
LINKWISE TECHNOLOGY PTE LTD
Blk 3 Ang Mo Kio Industrial Park 2A
#06-08, AMK TECH 1
Singapore 568050
Tel: 65-6484 6368 | Fax: 65-6484 6369
Email: adeel at linkwisetech.com
URL: http://www.linkwisetech.com| http://www.picobox.biz
More information about the En-Nut-Discussion
mailing list