Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How SPI works?
PostPosted: Wed Feb 24, 2010 8:40 am 
Offline

Joined: Fri Jan 08, 2010 12:20 pm
Posts: 6
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?


Top
 Profile  
 
 Post subject: Re: How SPI works?
PostPosted: Fri Feb 26, 2010 8:17 pm 
Offline

Joined: Thu Feb 25, 2010 5:02 pm
Posts: 88
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;

_________________
Duane P. Fridley, IEEE CSDP
Viable Bytes, Inc.


Top
 Profile  
 
 Post subject: Re: How SPI works?
PostPosted: Sun Feb 28, 2010 7:56 pm 
Offline

Joined: Fri Jan 08, 2010 12:20 pm
Posts: 6
Ok, thank you for your response.

I will try to configure it, following your advice.

Bye.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: