SPNA241 August   2019 RM41L232 , RM42L432 , RM44L520 , RM44L920 , RM46L430 , RM46L440 , RM46L450 , RM46L830 , RM46L840 , RM46L850 , RM46L852 , RM48L530 , RM48L540 , RM48L730 , RM48L740 , RM48L940 , RM48L950 , RM48L952 , RM57L843 , TMS570LC4357 , TMS570LC4357-EP , TMS570LC4357-SEP , TMS570LS0232 , TMS570LS0332 , TMS570LS0432 , TMS570LS0714 , TMS570LS0714-S , TMS570LS0914 , TMS570LS10106 , TMS570LS10116 , TMS570LS10206 , TMS570LS1114 , TMS570LS1115 , TMS570LS1224 , TMS570LS1225 , TMS570LS1227 , TMS570LS20206 , TMS570LS20206-EP , TMS570LS20216 , TMS570LS20216-EP , TMS570LS2124 , TMS570LS2125 , TMS570LS2134 , TMS570LS2135 , TMS570LS3134 , TMS570LS3135 , TMS570LS3137 , TMS570LS3137-EP

 

  1.   CAN Bus Bootloader for Hercules Microcontrollers
    1.     Trademarks
    2. Introduction
    3. Hardware Requirements
    4. CAN Settings
    5. Software Coding and Compilation
    6. Exception Vector Table
    7. ECC Generation for Bootloader Code
    8. ECC Generation for Application Code
    9. During Bootloader Execution
    10. Bootloader Flow
    11. 10 CAN Bootloader Operation
    12. 11 CAN Bootloader Protocol
    13. 12 Create Application for Use With the Bootloader
    14. 13 Sample Code for PC-Side Application
    15. 14 References

CAN Settings

The Hercules CAN is compliant with the 2.0A specification with a bitrate up to 1 Mbit/s. It can receive and transmit standard frames with 11-bit identifiers as well as extended frames with 29-bit identifiers. To change the CAN settings for the bootloader, knowledge of the CAN protocol, revision 2.0 is assumed. For details, see the CAN Protocol Revision 2.0 Specification.

Figure 3 shows the essential fields of the standard frame that is used in this CAN bootloader.

std_CAN_frame_format_spna182.gifFigure 3. Standard CAN Frame Format

Table 2. Commands Used in Bootloader

Commands CMD Description
PING 0x00 See Section 11
GET_ADDR_SIZE 0x01 See Section 11
GET_STATUS 0x03 See Section 11
GET_DATA 0x04 See Section 11
RESET 0x05 See Section 11
ACK 0x06 See Section 11

In this application, the CAN settings are:

  • Standard identifier
  • Baud Rate: 500 kbps is used by default.
  • Functions used: canInit()

The transmit settings (from MCU to the host) are:

  • Tx mailbox2: On -- #define MSG_OBJ_BCAST_TX_ID 1 inbl_dcan.c
  • Tx mailbox1: Off -- #define MSG_OBJ_BCAST_RX_ID 2 inbl_dcan.c
  • Tx identifier: 0x5A (device ID) + CMDs (0x00, 0x01, 0x02, 0x04, 0x05, 0x06)
  • Functions used: CANMessageSetTx(), and PacketWrite()

The receive settings (from the host to the MCU) are:

  • Synchronization (ACK), 0x06, is in the RX identifier and not in the data field.
  • RX identifier: device ID + CMDs
  • Error checking: Host re-transmits the frames that have lost arbitration or have been disturbed by errors during transmission.
  • Incoming messages can contain from 1 to 8 data bytes.
  • Functions used: CANMessageGetRx(), CANMessageSetRx(), and PacketRead()

CAN Bit timing setting:

Two clock domains are provided to the CAN module:

  • VCLK: general module clock source
  • VCLKA1: clock source to CAN_CLK for generating the CAN Bit Timing (system.c)
  • Functions used: canInit()

Both VCLK and VCLKA can be derived from the same clock source. However, if the frequency modulation in the FMPLL is enabled (spread spectrum clock), then, due to the high precision clocking requirements of the CAN Core, the FMPLL clock source should not be used for VCLKA. Alternatively, a separate clock without any modulation (for example, derived directly from the OSCIN clock) should be used for VCLKA.

Before configuring the CAN module, evaluate your system specifications such as system propagation delay (wire length and transceiver delay), crystal tolerance, and re-synchronization jump width. To initialize the CAN registers in CAN communication, you must define parameters such as baud rate, propagation segment (Prog_Seg), time segment 1 (Phase_Seg1) and time segment 2 (Phase_Seg2). Figure 5 shows the CAN BTR calculations in HalCoGen.

tprop = 2(tbus + ttransmitter + treceiver)

tbus = Bus Length (meter) * 5 ns/meter

ttransmitter and treceiver can be found in the device-specific transceiver data sheet

CAN_bit_timing_spna241.gifFigure 4. CAN Bit Timing
can1_timing_config.gifFigure 5. CAN Bit Timing Calculation in HalCoGen