On Tue, 2005-08-23 at 12:05 +0000, behrooz_hariri wrote: > Hi. In spi between two AVR, the data sequence which is important to > realize what byte is for temperature for example, and what was > indicating humidity, becomes corrupted when I reset the slave. How > can I distinguish in slave (receiver) which byte was sent first and > wich was the next? > > in master: > A(1) = "a" > A(2) = "b" > A(3) = "c" > Do > ... > Spiout A(1) , 3 > Loop > > -------- > in slave: > Do > Spiin A(1) , 3 > print A(1) ; A(2) ; A(3) > Loop You'll need to send some form of synch flag first, then the data in the order in which you have decided to send it. The receiver should not stoire any data until it has properly decodded the synch flag. A synch flag can be any byte or combination of bytes you wish. For example, if you're transfering 3 bytes of datam and they can eachor any of them can hold values between 00 and ff, then your synch should be a multiple of bytes, such that the same sequence can never occur as data (e.g., 4 FFs, or FF 00 FF 00, or whatever). once your receiver has logged a synch event, then it can start receiving and counting data bytes. Tom
Message
Re: [AVR-Chat] Sending multi-bytes sequence throgh SPI (AVR-Bascom)
2005-08-24 by Thomas Keller
Attachments
- No local attachments were found for this message.