[En-Nut-Discussion] Multiple devices on the SPI BUS
Bernd Walter
enut at cicely.de
Fri Sep 26 21:51:25 CEST 2008
On Wed, Aug 13, 2008 at 08:16:40AM -0400, ennut at thezachariasgroup.com wrote:
> Jae,
> The problem was with the processor.
> I have a EEPROM connected to PA12 which is SPI0_NPCS0.
> The SD/MMC is connected to PA13 which is SPI0_NPCS1
>
> The chip uses SPI_CSR1 for the SD/MMC card until there is activity on
> the EEPROM. Then the chip starts using SPI_CSR0 instead of SPI_CSR1
> for the SD/MMC card.
> (It took me a while to figure this one out)
>
>
> My solution:
> I put a semaphore that regulates both the SDCARD and EEPROM.
>
> Before a EEPROM operation I execute the following command:
> outr(SPI0_CSR0, uwEEPROM_CSR0); //
>
> Where uwEEPROM_CSR0 is the SPI_CSR value for the EEPROM.
>
> After a EEPROM operation is complete I execute the following command:
>
> outr(SPI0_CSR0, uwMMC_CSR1); // This did the trick
>
> Where uwMMC_CSR1 is the SPI_CSR value for the SD/MMC card.
> Note that this is written to SPI0_CSR0. This value should only have
> to be used for SPI0_CSR1.
>
>
> I have not tried to see what happens for the other two chip selects.
I'm currently facing a similar problem with a SAM7X256.
SPI flash on SPI0_NPCS2, MicroSD on SPI0_NPCS3
Two VS1033 on SPI1_NPCS0/1/2/3.
SPI1 works fine with my own code.
The MicroSD card works fine as well with Nut/OS code.
Now I want to use the flash on SPI0_NPCS2, but PHAT access can happen
from other threads.
Your suggestion sounds reasonable, but I'm a bit unsure about where
to place the locking in the Nut/OS code.
--
B.Walter <bernd at bwct.de> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
More information about the En-Nut-Discussion
mailing list