XMega SPI question

nwrightson
Benutzer
Avatar
Gender:
Location: Newcastle
Age: 63
Homepage: nweha.homeserver.c…
Posts: 362
Registered: 08 / 2003
Subject:

XMega SPI question

 · 
Posted: 22.11.2011 - 03:58  ·  #1
Hi,

In my design, I have 4 SPI slave devices. 1 Slave will be on the SPI_D port (Ethernet W5100) and the other 3 on the SPI_C port.
On the SPI_C port, they will all use the same MISO,MOSI & CLK but I have a separate SS for each.
They will be a :
- SD Card
- Touch Screen controller
- ??? Future enhancement

The issues I see are :
1. SS for each device. Plenty of pins and I'm guessing I need to use the "OnSPISS" Call back procedure? I have only seen one reference to this in another post and no information in the Help or either manual. Is this correct? How do I use this?

2. Different SPI Modes for each device ie
SPIorderD = MSB;
SPImodeD = 0; // Clock Phase and Polarity
SPIprescD = 1; // presc = 0..3 -> 4/16/64/128
I believe I can change the SPI Mode defines within the APP ????

3. If I use the FAT16 example as per the Help document
FAT16 = SPI_C, PortC, 2, iData; // PortX defines the SS-Port and n (6) the SS-Pin NYF
Does this mean that I don't need to handle the SS pin myself for MMC interfacing?
Just handle the SS for the Touch screen and future device?

4. Given that the system knows the correct SPI Mode details for the FAT16. Do I need to change it back each time I move from a TouchScreen SPI comms to FAT16 SPI comms?
If so, What is the SPI Mode for the FAT16?

Thanks,
Neil.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: XMega SPI question

 · 
Posted: 22.11.2011 - 12:40  ·  #2
Hello Neil,

did you read the Standard Driver Manual?
You can define separate CS/SS pins for each SPI. If more than one SPI slave should be connected to an SPI port then you must use

SPI_SSx = none;

and then the application must activate/deactivate the CS pins by itself.
Because of the different possible SPI modes the application also must do a SPI setup before each transaction (in case the modes are different). With FAT16 the best way is to read out once the concerned SPI registers and store the values for re-use. All AVrco drivers make the init at startup and not at each access.

rolf
nwrightson
Benutzer
Avatar
Gender:
Location: Newcastle
Age: 63
Homepage: nweha.homeserver.c…
Posts: 362
Registered: 08 / 2003
Subject:

Re: XMega SPI question

 · 
Posted: 22.11.2011 - 12:48  ·  #3
Rolf,

In regard to question 1. What is the "OnSPISS" Call back and how do I use it?
This is where it became confusing and is NOT mentioned in the manual, hence the need for clarification of the whole project.
Neil.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: XMega SPI question

 · 
Posted: 22.11.2011 - 13:15  ·  #4
Hello Neil,

there is only the "onFAT16_SS", described in the Profi Driver Manual.

rolf
nwrightson
Benutzer
Avatar
Gender:
Location: Newcastle
Age: 63
Homepage: nweha.homeserver.c…
Posts: 362
Registered: 08 / 2003
Subject:

Re: XMega SPI question

 · 
Posted: 22.11.2011 - 23:13  ·  #5
Rolf,
So what is the "OnSPISS" you refer to in the post? (Refer to the link in the first question)
Neil.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: XMega SPI question

 · 
Posted: 23.11.2011 - 00:11  ·  #6
Hello Neil,

this does only exist in complex drivers using an SPI on low level. With FAT16-SPI -> onFAT16_SS for example. Here is the complete list:

onTINA_SS
onWZ51_SS
onFAT16_SS

rolf
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   111   125 · Page-Gen-Time: 0.023821s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI