Download Directed Electronics 3200HS Technical information

Transcript
SCI to SPI Peripheral Communication in V850ES Microcontrollers
Main( ) then calls Temp_Init( ) to initialize the temperature sensors and the CSI/SPI interface used
to communicate with the sensors. If an error is detected, an error code is displayed and the program
enters an endless loop.
To indicate proper initialization, a pair of dashes is shown in the LED. TM00_Start( ) is called to
start the TM00 timer for a periodic 1 millisecond interrupt, used for debouncing the input switches.
The main( ) program then enters the main program loop. The program checks the state of the SW2
and SW3 switches for the action to perform.
Figure 12.
Main( ): Main Program for NEC Electronics CSI to SPI Serial Communication
A
Initialize switches and LED display
B
CALL Temp_Init( )
Display “- -” in LED display
CALL TM00_Start( ) to debounce
Get state of SW2 and SW3
SW2 only?
Yes
No
SW3 only?
temp = Temp_Read_1( )
CALL Temp_Display(temp)
Wait for switches different
Yes
Temp = Temp_Read_2( )
C
E
D
No
CALL Temp_Display(temp)
Wait for switches different
E
If SW2 is pressed, the MAX6627 temperature sensor is read by calling Temp_Read_1( ), and the
variable temp is set to the value read. The temperature is then displayed in the LED by calling
Temp_Display(temp). Main() then waits for the switch state to be different.
If SW3 is pressed, the DS1722 temperature sensor is ready by calling Temp_Read_2( ), setting
temp to the value read. The temperature is then displayed in the LED by calling
Temp_Display(temp). Main() then waits for the switch state to be different.
17