Technical information
CSI to SPI Peripheral Communication in V850ES Microcontrollers
Figure 18. CSI00_ReceiveData(*rxbuf, rxnum): Prepare To Receive Data on CSI00
GG
Return
CSI00_RX_LEN = rxnum
CSI00_RX_CNT = 0
CSI00_RX_ADDRESS = rxbuf
CSI00_RX_LEN = rxnum
CSI00_RX_CNT = 0
CSI00_RX_ADDRESS = rxbuf
2.6.9 MD_INTCSI00() : Interrupt Service Routine for INTCSI00
The MD_INTCSI00() routine is the interrupt service routine for the INTCSI00 interrupt, which
occurs after a byte of data has been transmitted by the CSI00 peripheral. The routine handles
transmission of the next byte, optional storing of received data, and setting flags to notify the main
program of send or receive complete.
The routine first checks if CSI00_TX_CNT (count of bytes sent) is equal to CSI00_TX_LEN
(number of bytes to send). If so, the last byte has been sent, and the callback routine
CALL_CSI00_Send() is called. This routine sets the flag CSI00_SendDone to TRUE.
If the send count is less than the number to send, then additional data needs to be sent. The next
byte to send, pointed to by CSI00_TX_ADDRESS, is written to the SOTB0L register for
transmission; CSI00_TX_ADDRESS is incremented to point to the next byte, and
CSI00_TX_CNT is incremented.
When a byte of data is transmitted by being shifted out on the SO output, a separate byte is
simultaneously received by shifting data in on the SI input. After a byte has been sent, the received
byte is available in the SIRB0L register and in the SI000 serial shift register. Once another byte
has begun transmitting, the SI000 serial shift register may no longer contain the previous data, but
it is still available in the SIRB0L register.
The MD_INTCSI00() routine checks if data should be received by checking for CSI00_RX_LEN
being non-zero. If CSI00_ReceiveData() has been called with an non-zero rxnum parameter, this
will be the case. The routine then checks to see if CSI00_RX_CNT plus one is less than
CSI00_RX_LEN, which will be true for bytes 0 through n-1 of an n-byte receive. If this is the
case, data is read from the SIRB0L register, and stored at the location pointed to by
CSI00_RX_ADDRESS. The address and count are then incremented.
If the count plus one is not less than the length, this is the last byte to receive, and the data is read
directly from the SI000 register, stored at the address, and the count is incremented. The callback
routine CALL_CSI00_Receive() is called, which sets the CSI00_ReceiveDone flag.
24