Application Example 4—Full-Speed FlexRay and CAN Networks
S12XF Starter Kit, Rev. 1
Freescale Semiconductor
7
•
SPI master operating at 2.5 MHz
•
SBC initialized in debug mode
•
CAN module configured for internal loopback transmission and reception at 500 Kbit/s
•
FlexRay module configured for wake-up frames transmission
•
Periodic XGATE access to SBC through SPI channel, 75 ms period
•
Microcontroller successive tasks are separated by 225 ms intervals for a total period of 900 ms; the
general-purpose LEDs are activated by columns to indicate the task executed in the following
sequence:
— CAN internal loopback transmission/ reception, LED indicators D22, D27 and D29
— FlexRay wake-up frames transmission, LED indicators activated D23, D25 and D28
— D24 and D26 toggled
— LED indicators off
•
IRQ detection when SW2 is pressed, interrupt service indicated by toggling D26
•
Input capture IOC7 stimulated by SW3, interrupt serviced by the XGATE and indicated by
toggling D24
9
Application Example 4—Full-Speed FlexRay and CAN
Networks
For this example you need two EVBs, because each acts as a CAN and FlexRay node, exchanging frames
in a simple network. One EVB must be programmed using the EVB9S12XF512E_Node1_FS.mcp project.
The other must be programmed with the EVB9S12XF512E_Node2_FS.mcp code (these files are in the
EVB9S12XF512E_Node1_FS.zip and EVB9S12XF512E_Node2_FS.zip files, respectively). The CAN
and FlexRay channels must be properly connected between the EVBs.
The main functions performed in this example project are:
•
Real-time interrupt configured to 75 ms period and used as the base time for the task scheduler
•
SPI master operating at 2.5 MHz
•
SBC initialized in debug mode
•
CAN module configured for transmission and reception at 500 Kbit/s rate
•
FlexRay module fully configured for frames transmission and reception at 10 Mbit/s. In Node1 the
FlexRay events are interrupt driven, whereas in Node2 there is a polling procedure for the frames
handling
•
LED D22 toggled each time the RTI is serviced (75 ms period)
•
Periodic XGATE access to SBC through SPI channel (75 ms period)
•
CAN frames transmission every 150 ms; LED D27 activated
•
CAN reception is interrupt based; LED D29 is activated to indicate a CAN frame received
•
FlexRay activity is indicated by the fast toggling of LEDs D23, D25, and D28. To ease visual
perception, these LEDs are turned on each time the RTI is serviced and turned off when a FlexRay
function is performed. For Node1 the LED activation is: