Anders Johansson

SPI, how to know when CS can be returned high, Processor Expert beans

Discussion created by Anders Johansson on Jan 18, 2011
Latest reply on Jan 19, 2011 by kef

HCS12XEP100, CW 4,7 and Processor Expert Synchromaster bean.




I need to send more than one byte while CS is active low.

I use a port to generate CS.

How do I detect that all SPI clocks have been generated, allowing me to return CS high?




I use a MCP2515 CAN controller.

It needs 3 SPI bytes to read a register on the MCP

Byte 1: "Read command"

Byte 2; "Register selection"

Byte 3: "Dummy byte" to generate the clocks needed to output the register content


For some reason I seem to need to use the bean function RecvChar twice,

with a slight delay between them, in order to read the register back.

The delay is also related to the clock setting used.

The faster the clock the less delay needed.


How do I determine when the clocking is done, allowing me to read the data received?

Will data received while clocking the first 2 bytes need reading/clearing,

or is it always the data clocked in last that is available?




When the MCP generates a interrupt I need to acknowledge it in the ISR,

to release the interrupt line.

Are there any limitations in how the Processor Expert bean(s) can be used in a ISR?


Thanks for any comments,

Anders J