[En-Nut-Discussion] Failed to mount sdcard using, at91sam7x-ek.conf, fails to write to SPI [Fixed]

Ole Reinhardt ole.reinhardt at embedded-it.de
Mon Apr 15 10:10:35 CEST 2013


Hi Adeel,

Good work! Thanks for your patch!

I'll add it to the trunk today (and add a comment with the hint to the
datasheet :)

Best regards,

Ole


Am 13.04.2013 14:48, schrieb Adeel Ahmed Nafis:
> Message: 1
> Date: Fri, 12 Apr 2013 22:27:32 +0800
> From: Adeel Ahmed Nafis <adeel at linkwisetech.com>
> To: en-nut-discussion at egnite.de
> Subject: [En-Nut-Discussion] Failed to mount sdcard using
>     at91sam7x-ek.conf, fails to write to SPI
> Message-ID: <516819D4.3070406 at linkwisetech.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> 
> Figured out, in At91SpiMmcIfcInit() spimmc_at91.c we need to call Reset
> on SPI twice.
> 
> --- a/nut/arch/arm/dev/atmel/spimmc_at91.c  Fri Apr 12 10:29:39 2013 +0800
> 
> +++ b/nut/arch/arm/dev/atmel/spimmc_at91.c  Sat Apr 13 19:00:06 2013 +0800
> 
> @@ -370,6 +370,7 @@ static int At91SpiMmcIfcInit(NUTDEVICE *
> 
>  
> 
>      /* SPI enable and reset. */
> 
>      outr(MMC_SPI_CR, SPI_SPIEN | SPI_SWRST);
> 
> +    outr(MMC_SPI_CR, SPI_SPIEN | SPI_SWRST);
> 
>      outr(MMC_SPI_CR, SPI_SPIEN);
> 
>  
> 
>      /* Set SPI to master mode, fixed peripheral at CS1, fault detection
> disabled. */
> 
> 
> 
> This is mentioned in the datasheet too pp652.
> 
> 41.4.8.7
> 
> SPI: Software Reset must be Written Twice
> 
> If a software reset (SWRST in the SPI Control Register) is performed,
> the SPI may not work
> 
> properly (the clock is enabled before the chip select.)
> 
> Problem Fix/Workaround
> 
> The SPI Control Register field, SWRST (Software Reset) needs to be
> written twice to be cor-
> 
> rectly set.
> 
> 
> 

-- 
kernel concepts GmbH            Tel: +49-271-771091-14
Sieghuetter Hauptweg 48         Mob: +49-177-7420433
D-57072 Siegen
http://www.embedded-it.de
http://www.kernelconcepts.de


More information about the En-Nut-Discussion mailing list