Hello, Gary! You wrote on 09 Dec 2004 11:40:57 GMT:
GK> If you really want to see just your data come across, you need to setup GK> the first data byte on initialization. When the master starts clocking, Do you mean, I should write byte into SPDR at my SPI_SlaveInit function? If so, should I also wait for transfer complete or at that stage it's quite enought just store value in the SPDR register? But if slave doesn't initiate a transfer it can silently wait for a moment when master starts transfer. I don't quite understand why should I write byte at slave init? GK> so will the slave. I don't know what triggers your SIG_SPI, maybe the GK> toggling of SS? If so, then you have only the amount of time from the As I understood datasheet, interrupt will be invoked as soon as transfer of byte will be completed. GK> changing of SS to the Master starting to clock in order to get your GK> data into the data register if it wasn't put there previously. I'm not
[skip]
GK> What you probably want to do in this specific case is:
GK> on slave init: setup for SPI Slave, then write first byte of data into GK> SPDR.
GK> after transmission complete: get next data byte and write into SPDR for GK> next transmission. ok, I'll follow your advice ??>> char *t; ??>>
??>> t = data; ??>> while ( *data != 0 ) { ??>> SPI_SendByte((char *)data); ??>> data++; ??>> } ??>> data = t;
GK> Quite frankly, I also don't like this. You change the global variable "data" GK> and then restore it. Why not just change the temporary "t" and do away with the GK> restore? Only change a global if that side effect is required. In this case, may be it's better to declare 'char *t' as global volatile variable and use it, or it's rather useless ?
With best regards, Roman Mashak. E-mail: snipped-for-privacy@tusur.ru