CY8CKIT-017 CAN/LIN Expansion Board Kit Guide, Doc. # 001-57814 Rev. *D
51
Code Examples
5.3.1
Firmware Flowcharts
Figure 5-34. Main Firmware Flowchart
Start
Initialize LCD, Timer,
Timer_ISR
Components
Print Welcome Message
“LIN Slave Example Ver
1.0” on LCD
Delay of 2 secs
Display “Send 8
bytes of data with ID
0x10” on LCD
Flag of
InFrame Set?
Clear InFrame Flag.
Set flags Data_Recvd_Flg
and Data_Recvd_FirstCap.
Clear LCD Display
Yes
No
Initialize LIN Core, LIN
Slave Component
Display “LINS Initialize
Successful” on LCD
Delay of 2 secs
Read the Value of
InSig1 and write to
OutSig1
Read the data of InArraySig
to an array using API
l_bytes_rd_InArraySig
Display “RecdData ID 0x10 –
xx xx xx xx xx xx xx xx (data
present in signals
InSig1 and
InArraySig)” on LCD
Is Flag of
OutFrame Set?
Write Data of
Signal
InArraySig to
OutArraySig
Display “DataSent ID 0x11 -
xx xx xx xx xx xx xx xx (data
present in signals Out
Sig1 and
OutArraySig)” on LCD
No
Yes
Clear LCD Display
Set Reset LCD_TimerCntr
Variable to 0. Start the Timer
to count 12 seconds
Is Flag
Data_Recvd_First
Cap Set?
Yes
Set Data_Sent_Flg, Stop
Timer, Reset LCD_TimerCntr
variable to 0. Restart the
Timer to count 12 seconds
Is
LCD_TimerCntr
=2?
Clear
OutFrame Flag
Reset
LCD_TimerCntr
Variable to 0.
Stop Timer
Is
Data_Recvd_Flg
Set?
Display “Send ID
0x11 to read
back data” on
LCD
Clear
Data_Recvd_Flg
and LCD Display
Yes
Yes
Clear
Data_Sent_Flg
and LCD Display
Display “Send 8
bytes of data with ID
0x10” on LCD
No
No
No
Init
Successful?
Display “IFC_INIT – FAIL
CPU HALTED” on LCD
Halt CPU
Yes
No