yeison wrote:
I have a doubt with the interpretation of the datasheet for the SPI interface.
In Master mode you have two ways to select peripheral: Fixed or Variable.
As per I can understand, the fixed peripheral select only allows have one slave working in each moment but for example you can have until 4 slaves. On the contrary, the variable peripheral select can have until 4 slaves (without external deco 4-16) working at the same time with the same clock and mode. Could you explain me if this is right?
In my application I have to use the AT91SAM7s256 with the ECN28J60 Ethernet Controller with SPI interface and another SPI port for a RFID reader chip. Which is the valid mode for me?
Think of it this way
Fixed = you manage the CS lines
Variable = SPI module manages the CS lines
So for Variable. PS=1 PCSDESC=0.
Set up the CSR registers for each peripherial. (e.g. Ethernet on CS1 setup CSR1).
Then when sending data to a peripheral load the SPI_TDR register with the data AND set the PCS field with the correct value. If the data being sent is the last make sure you set the LASTTXFER bit also.
e.g.
Sending to peripherial located on CS2:
Code:
const UINT32 PCS_CS2 = 0x00030000;
const UINT32 PCS_LASTTXFER = 0x01000000;
UINT32 temp;
temp = dataToSend;
temp |= PCS_CS2;
if(lastByte == true)
{
temp |= PCS_LASTTXFER;
}
SPI_TDR = temp;