TMS320F28P650DH: SysConfig configuration of CAN peripheral with AUXCLK

Part Number: TMS320F28P650DH
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

Hi team,

 

I am facing an issue on SysConfig with configuring CAN peripheral of F28P65 MCU at 500khz with clock source set to AUXCLK.

I'm testing on an F28P65 LaunchPad, supplying AUXCLK of 20MHz with a function generator, and observing the CAN bus with a bus analyzer.

Running the 'can_ex1_loopback' example from the SDK works well and frames are being received correctly on the bus analyzer.

However, when I change the clock source from Peripheral SYSCLK to AUXCLK in the clock tree of sysconfig, the bitrate (as observed on an oscilloscope) is not 500khz.
image.png

Changing the value of SysConfig>CAN>'Bit Rate Parameters'>'Device SYSCLK MHz' to 20 (to match AUXCLK) yields 250khz CAN bit clk (as observed on oscilloscope).

Setting this parameter to 10 yields 500khz CAN bit clk. However, the bus analyzer is not receiving the frames likely due to differences in sampling point.

 

Furthermore, I observed that changing the value of AUXCLK in clocktree does not change anything in the generatde code!

 

Please help me configure CAN at 500kHz bitrate with clock source set to AUXCLK.

 

Thanks.

  • Hi team,

    In the TRM, I don't see an option for selecting AUXCLK as a clock source in the CANABCLKSEL register, however, it is available in the clock tree of SysConfig - 

    Is this an error in the TRM or SysConfig?

    Thanks

  • Hi Dhruva,

    Which version of SysConfig and C2000Ware are you using? 

    Thanks,

    Ira

  • Hi Ira,

    SysConfig - 1.28.0

    C2000ware - 26.1.0.00

    Thanks,

    Dhruva

  • Hi Dhruva,

    I observed that the sysconfig generated board.c does not have any code related to the clock source, which is weird. I'll check on this.

    Meanwhile as a workaround, you can override sysconfig generated and manually initialize the CAN module so you aren't blocked by this

    For example it can look something like this, please check the driverlib APIs correctly in C:\ti\c2000\C2000Ware_26_01_00_00\driverlib\f28p65x\driverlib\can.c and C:\ti\c2000\C2000Ware_26_01_00_00\driverlib\f28p65x\driverlib\can.h

    void initCAN_with_AUXCLK(void)
    {
    // Step 1: Hardware clock routing (Manually overriding SysConfig)
    // This must happen AFTER Device_init()
    CAN_selectClockSource(CAN_BASE, CAN_CLOCK_SOURCE_AUXCLK);

    // Step 2: Configure Bit-Timing for 500kHz
    CAN_ConfigParams canCfg = {
    .brp = 1U, // Prescaler = 2
    .tseg1 = 14U, // 14 TQ
    .tseg2 = 5U, // 5 TQ
    .sjw = 1U, // 1 TQ
    .enableLoopBack = false,
    .enableListenOnly = false
    };

    // Step 3: Apply configuration
    CAN_initModule(CAN_BASE, &canCfg);
    CAN_enableModule(CAN_BASE);
    }

    int main(void)
    {
    Device_init(); // Generated by SysConfig (sets default SYSCLK)
    Device_initGPIO(); // Generated by SysConfig

    initCAN_with_AUXCLK(); // Your custom manual configuration

    while(1) {
    // Application loop
    }
    }

    make sure to add this in a separate .c file and NOT in the board.c (as this will get regenerated every time your rebuild the project)

    You can try this workaround while I check why the actual sys config gui does not work.

  • Hi Ira,

    I was able to get CAN up and running at 500khz with AUXCLK with this initialization - 

     

    void Can_Init()
    {
        CAN_disableAllMessageObjects(CANA_BASE);
    
        CAN_disableController(CANA_BASE);
    
        CAN_selectClockSource(CANA_BASE, CAN_CLOCK_SOURCE_AUX); //set clk source to aux
    
        CAN_enableController(CANA_BASE);
    
        //
        // Initialize the CAN controllers
        //
        CAN_initModule(CANA_BASE);
    
        //
        // Set up the CAN bus bit rate to 500kHz for each module
        // Refer to the Driver Library User Guide for information on how to set
        // tighter timing control. Additionally, consult the device data sheet
        // for more information about the CAN module clocking.
        //
       
        CAN_setBitRate(CANA_BASE, DEVICE_OSCSRC_FREQ, 500000, 20);  //20MHz auxclk freq
    
        //
        // Enable CAN Auto-Bus-On
        //
        CAN_enableAutoBusOn(CANA_BASE);
    
        //
        // Set Auto-Bus-On Timer - 300 Sysclock cycles
        //
        CAN_setAutoBusOnTime(CANA_BASE, 300);
        
        /*
        ...interrupt configs
        */
    }

    Apart from the code generation issue of clock source, please answer these - 

    1. What is the functionality of SysConfig>CAN>'Bit Rate Parameters'>'Device SYSCLK MHz'? What value is to be added in this field when clock is not derived from CPU SYSCLK (PERx.SYSCLK)? 

    2. "In the TRM, I don't see an option for selecting AUXCLK as a clock source in the CANABCLKSEL register, however, it is available in the clock tree of SysConfig" Please confirm if this is an error in TRM.

    Additionally, I noticed that in the CAN examples (C2000Ware > English > Devices > F28P65X > F28P650DK9 > Examples > Driverlib > c28x > can), apart from ex 1 (loopback) and ex 7 (loopback_tx_rx_remote_frame), the other examples have EMPTY SysConfig files (c2000.syscfg) with NO configurations! Please do fix this as well. 

    Thanks,

    Dhruva 

  • Hi Dhruv,

    1. Enter the actual frequency of whatever source you are routing to CAN (e.g., 20 MHz for AUXCLK, 10 MHz for LSPCLK, etc.). Enter the value in MHz.

    2. Im confirming with the team that owns TRM creation/ maintenance. If they confirm, I will file it as a litbug and have it fixed.

    Thanks,

    Ira

  • Hi Dhruva,

    I just checked with the team and looks like this is an error with the TRM. Usually, we get the register list from design and it looks like this was a bug in the registers xls that was fixed but wasn't ever propagated to the TRM. Fields for both MCANABCLKSEL and MCANBBCLKSEL should be identical (MCANABCLKSEL in the TRM is correct).

    We'll fix this when there is a refresh for gen 3 TRMs

    Cheers!

    Ira