Technical information
CSI to SPI Peripheral Communication in V850ES Microcontrollers
The routine sets the CSI00_SendDone flag to FALSE, and writes two dummy bytes by calling
CSI00_SendData(txbuf, 2). Because the CSI00 peripheral is in transmit/receive mode, in order to
receive data, the transfer must be started by writing a byte of data to the SOTB0L register. This
data will be sent out the SO00 output, which is not connected to the MAX6627; the first eight bits
of data from the MAX6627 will be clocked in on the SI00 input. Reception of the second eight bits
of data is done during the transmission of the second dummy byte.
Figure 20. Temp_Read_1(): Read Temperature Sensor 1 (MAX6627)
Delay 100ns after CS activeDelay 100ns after CS active
HH
TEMP1_CS_ON (P9H.7 = 0)TEMP1_CS_ON (P9H.7 = 0)
CSI00_SendDone = FALSE
CALL CSI00_SendData(txbuf, 2)
CSI00_SendDone = FALSE
CALL CSI00_SendData(txbuf, 2)
FF
CALL CSI00_ReceiveData(rxbuf, 2)CALL CSI00_ReceiveData(rxbuf, 2)
Yes
No
SendDone
== FALSE?
Yes
No
SendDone
== FALSE?
TEMP1_CS_OFF (P9H.7 = 1)TEMP1_CS_OFF (P9H.7 = 1)
retval = rxbuf[0] << 8
retval = retval | (rxbuf[1] & 0xF8)
retval = rxbuf[0] << 8
retval = retval | (rxbuf[1] & 0xF8)
Return retval
GG
CALL CSI00_SetType4( )CALL CSI00_SetType4( )
EE
The routine then waits for the CSI00_SendDone flag to be set to TRUE, which will be done by the
MD_INTCSI00() interrupt service routine after the last byte of data is transmitted, which will also
have clocked in the last byte to receive.
Temp_Read_1() then sets the temperature sensor chip select off, to have the sensor resume
temperature readings. It then combines the bytes in rxbuf[0] (first eight bits from MAX6627 =
Temperature MSB), and rxbuf[1] (second eight bits from MAX6627 = temperature LSB) into a
signed 16-bit value. It masks the lowest three bits, and returns the 16-bit signed value, which is
temperature × 128.
2.6.11 Temp_Read_2(): Read Temperature Sensor 2 (DS1722)
The Temp_Read_1() routine reads the latest temperature reading from the DS1722 temperature
sensor, and returns the value read as a signed 16-bit value, equivalent to (temperature in ºC) × 128.
First the CSI00_SetType3() routine is called, to set the CSI00 transfer type to the proper setting for
this device. Then the chip select for the temperature sensor is set on (active high). A short delay is
inserted to allow 400 ns from chip select to the first serial clock.
26