Keep in mind that SPIDR is not a read/write register. It a one write-only register (the transmitter) sharing the address with one read-only register (the receiver). In effect, you are not seeing the data that the SPI should be receiving, or you are but it never changes.
Any idea how I can prevent a R/W register from being written?
Message Edited by bigmac on 2006-09-08 03:37 PM
void SPI_func(void) { int i; PTG_PTG2 = 0; // Drive SS* low for (i=0; i3; i++) // send command string { SPIDR = in_buf[i]; // Send 0xA4 while ((SPISR & 0x20) == 0) ; // Transmit buffer empty } for (i=0; i6; i++) // receive response { SPIDR = 0; // start transfer while ((SPISR & 0x20) == 0) ; // Transmit buffer empty out_buf[i] = SPIDR; // Receive } SPIDR = 0; // one last transfer to wait for the buffering while ((SPISR & 0x20) == 0) ; // Transmit buffer empty for the last time PTG_PTG2 = 1; // Drive SS* high }