EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Software SPI

Started by terry November 15, 2004
Hi,

Could anyone give me AVR source code to implement SPI by software? I
need it because I want to have SPI and also external interrupt on
ATTiny22. But the pins are overlapped if the two functions are used.

Thanks!
"terry" <leonlai2k@yahoo.com> wrote in message 
news:9904d48.0411150142.1e635596@posting.google.com...
> Hi, > > Could anyone give me AVR source code to implement SPI by software? I > need it because I want to have SPI and also external interrupt on > ATTiny22. But the pins are overlapped if the two functions are used.
Atmel has an app. note with software SPI receive. I modified it for transmit using a '2313, and it worked fine, communicating with a PIC with hardware SPI. Leon -- Leon Heller, G1HSM http://www.geocities.com/leon_heller
"Leon Heller" <leon_heller@hotmail.com> wrote in message 
news:41988911$0$15428$cc9e4d1f@news-text.dial.pipex.com...
> "terry" <leonlai2k@yahoo.com> wrote in message > news:9904d48.0411150142.1e635596@posting.google.com... >> Hi, >> >> Could anyone give me AVR source code to implement SPI by software? I >> need it because I want to have SPI and also external interrupt on >> ATTiny22. But the pins are overlapped if the two functions are used. > > > Atmel has an app. note with software SPI receive. I modified it for > transmit using a '2313, and it worked fine, communicating with a PIC with > hardware SPI.
Sorry, that should read SPI master instead of SPI receive. I actually modified it for slave operation, with a PIC SPI master. Leon
Leon Heller wrote:
> "Leon Heller" <leon_heller@hotmail.com> wrote in message > news:41988911$0$15428$cc9e4d1f@news-text.dial.pipex.com... > >>"terry" <leonlai2k@yahoo.com> wrote in message >>news:9904d48.0411150142.1e635596@posting.google.com... >> >>>Hi, >>> >>>Could anyone give me AVR source code to implement SPI by software? I >>>need it because I want to have SPI and also external interrupt on >>>ATTiny22. But the pins are overlapped if the two functions are used. >> >> >>Atmel has an app. note with software SPI receive. I modified it for >>transmit using a '2313, and it worked fine, communicating with a PIC with >>hardware SPI. > > > Sorry, that should read SPI master instead of SPI receive. I actually > modified it for slave operation, with a PIC SPI master. > > Leon
Please note that a software SPI slave is in a very difficult timing position: all transfers are timed solely by the master and the slave must be fast enough to keep up, This will usually mean thet the slave has to use most of the processing time polling the SPI clock. -- Tauno Voipio tauno voipio (at) iki fi
> Please note that a software SPI slave is in a very difficult > timing position: all transfers are timed solely by the master > and the slave must be fast enough to keep up, This will usually > mean thet the slave has to use most of the processing time > polling the SPI clock.
Polling? Why not interrupt-on-change?
Tauno Voipio <tauno.voipio@iki.fi.NOSPAM.invalid> wrote in message news:<Hgimd.31$y75.0@read3.inet.fi>...
> Leon Heller wrote: > > "Leon Heller" <leon_heller@hotmail.com> wrote in message > > news:41988911$0$15428$cc9e4d1f@news-text.dial.pipex.com... > > > >>"terry" <leonlai2k@yahoo.com> wrote in message > >>news:9904d48.0411150142.1e635596@posting.google.com... > >> > >>>Hi, > >>> > >>>Could anyone give me AVR source code to implement SPI by software? I > >>>need it because I want to have SPI and also external interrupt on > >>>ATTiny22. But the pins are overlapped if the two functions are used. > >> > >> > >>Atmel has an app. note with software SPI receive. I modified it for > >>transmit using a '2313, and it worked fine, communicating with a PIC with > >>hardware SPI. > > > > > > Sorry, that should read SPI master instead of SPI receive. I actually > > modified it for slave operation, with a PIC SPI master. > > > > Leon > > > Please note that a software SPI slave is in a very difficult > timing position: all transfers are timed solely by the master > and the slave must be fast enough to keep up, This will usually > mean thet the slave has to use most of the processing time > polling the SPI clock.
Thanks!
"Lewin A.R.W. Edwards" <larwe@larwe.com> wrote in message 
news:608b6569.0411160429.54257c12@posting.google.com...
>> Please note that a software SPI slave is in a very difficult >> timing position: all transfers are timed solely by the master >> and the slave must be fast enough to keep up, This will usually >> mean thet the slave has to use most of the processing time >> polling the SPI clock. > > Polling? Why not interrupt-on-change?
Probably because the original poster wanted to use the interrupt for something else. Sound like he needs to rethink the problem. Peter

The 2024 Embedded Online Conference