closed

Loginbox

Please enter your username and password into the following fields to log in.


  • Username:
  • Password:
  •  
  • Auto log in on every visit.


  •  

SPI SLave



Droopy offline
Benutzer
Avatar
Gender: male
Location: BELGIUM 
Age: 51
Posts: 20
Registered: 01 / 2016
Private message
Subject: SPI SLave  -  Posted: 10.08.2017 - 00:06   -  
Hey all,

There is an easy spi master port in avrco, but is there also a simple spi slave driver in avrco for the xmega?
Someting similar like there is for the serport :
- an import were to configure the spi port (Slave, mode0..4, bit order)
- a tx buffer you can put data that is shift out if the spi master delivers the clock (interrupt based?)
- a rx buffer that is holding the bytes that were shifted in by the spi master (interrupt based?)

The setup I have is as follows:
An xmega with a spi master port that is connected to a LCD display with spi bus. On that same bus I need to connect a second xmega (working as slave). The load of the slave xmega is high but the communication between master and slave is minor.
(Taking other ports on the xmega is not an option)

Thanks for some help ;)

Peter
go down go up
rh offline
Administrator
Avatar
Gender: male
Location: GERMANY  Germany
Age:
Posts: 5109
Registered: 03 / 2002
Homepage Private message
Subject: Re: SPI SLave  -  Posted: 14.08.2017 - 14:24   -  
Hello Peter,
in my opinion an SPI slave makes no sense when implemented
in an uC. The SPI Master expects always an answer at the time
when he sends a request. So the slave must write the expected
answer into the SPI Tx register bevore the Master vsends a request.
ok, one can implement an overlaying protocol which reads the
first request and then responds in the second request.
But there is a fürther quirk when the Slave is not fast enough
and misses any request. Think of interrupts and multi tasking.

The setup of a Slave SPI is easy but the necessary overlaying
protocol is very dependend of the user program so there it isn´t
possible to build a generic driver in AVRco. Use one of the several
UARTs in the XMega and your are on the right side.

rolf
Cars don't buy cars -- Autos kaufen keine Autos.
Henry Ford
go down go up
Merlin offline
Schreiberling
Avatar
Gender: male
Location: UNITED KINGDOM 
Age:
Posts: 746
Registered: 03 / 2005
Private message
Subject: Re: SPI SLave  -  Posted: 14.08.2017 - 14:42   -  
FWIW

I have created SPI slaves using MEGA (not XMEGA chips), and they worked very well, but Rolf is right in his concerns. The temptation is to run SPI as fast as possible, but if you are using MEGAs as slaves you actually need to run SPI as slowly as possible to get reliable operation - it should still be plenty fast enough. In fact I deliberately ran the master with a slow crystal just to make sure. This is not the way the AVRCo SPI master is implemented, and if I were doing it again I would, as Rolf suggests, use the UARTS.

In summary - been there, done that, wouldn't do it again.
Merlin.

:magic:

Software is a black art.
go down go up
Droopy offline
Benutzer
Avatar
Gender: male
Location: BELGIUM 
Age: 51
Posts: 20
Registered: 01 / 2016
Private message
Subject: Re: SPI SLave  -  Posted: 17.08.2017 - 14:03   -  
Sorry for the late respons ;)

Thanks a lot for your info.
The information between master and slave avr is not a lot and can be slow. But like you suggest, the uart can also be used.
The only problem is that I wanted the LCD to be driven from the master avr and the LCD has only spi bus.
What I maybe can do, is use a uart connection between master and slave avr and connect the LCD to the slave avr trough spi bus.
The protocol over the uart than need to be expand with the communication for the LCD : the slave avr act like a uart/spi gateway between master avr and LCD.

Thanx all ;)
go down go up
Merlin offline
Schreiberling
Avatar
Gender: male
Location: UNITED KINGDOM 
Age:
Posts: 746
Registered: 03 / 2005
Private message
Subject: Re: SPI SLave  -  Posted: 17.08.2017 - 15:19   -  
Hi Peter.

Another option might be the SC16IS750 chip, which converts I2C to UART. That might avoid the extra complications.
Merlin.

:magic:

Software is a black art.
go down go up
Droopy offline
Benutzer
Avatar
Gender: male
Location: BELGIUM 
Age: 51
Posts: 20
Registered: 01 / 2016
Private message
Subject: Re: SPI SLave  -  Posted: 17.08.2017 - 23:04   -  
Thnx Merlin.

I gonna reevaluate the whole setup and verify all possibilities I have without the spi master slave ;)

Peter
This post has been edited 1-times. Last edit: 17.08.2017 - 23:04 by Droopy.
go down go up
 


Registered users in this topic
Currently no registered users in this section

Delete cookies of this forum  •  FAQ / Help  •  Team page  •  Imprint   |  Local time: 17.10.2017 - 09:50