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

Adeel Ahmed Nafis adeel at linkwisetech.com
Sat Apr 13 14:48:22 CEST 2013


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.



-- 
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