Rene Heppell

9S12X SPI handling SPIE, SPTIE

Discussion created by Rene Heppell on Nov 10, 2008
Latest reply on Nov 11, 2008 by kef
I have a question on the proper usage of the SPI Interupts and the SPISR register flags. (SPIF, SPTEF, MODF)

In my current design, I am sending data accross MOSI and then Enabling SPTIE, once the interupt fires I assume data has been sent and Disable SPTIE. I do this for every Transmit. When I want to receive information I need to "clock" it, so I send dummy 8 bytes, and wait for received information which seems to set the SPIF flag and clear it before I read SPISR, or fire the interupt.

Example:
EEPROM Read Operation:
1) Send Read Instruction, Enable SPTIE. (Interupt occurs after TX, disables SPTIE, goes to next operation)
2) Send Address, Enable SPTIE. (Interupt occurs after TX, disables SPTIE, goes to next operation)
3) Send 0x00 to Clock in 8 Bytes of data on Receive (MISO) line.
 -> Wait on SPIE interrupt for received data. (Not functioning properly)

*Note CS is active low for the entire operation.

Is there a better way than Disabling/Enabling the interupt, and how can I track the incomming data?

Outcomes