This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LC4357: HALCoGen Safety Lib example fails with SL version 2.3.1, succeeds with 2.2.0

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

When I run the HALCoGen (v 4.06.01) example for the Safety Lib (example_SafetyLib.c),
it performs fine with Safety Lib version 2.2.0.

If I run the same example, with identical code, agains Safety Lib version 2.3.1, it hangs in the first DCAN check.
It gets locked in this while() becaus the test fails:

        	if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_1BIT, SL_DCAN1) == false)
        	{
        		while(1);
        	}

The location where it fails is:

    /* verify DCAN is initialised */
    /*SAFETYMCUSW 439 S MR:11.3 <APPROVED> Comment_4*/
    if((boolean)sl_canREG)
    {
        /*SAFETYMCUSW 134 S MR: 12.2 <APPROVED> Comment_5*/
    	if ((uint32)CAN_INIT_BIT == (sl_canREG->CTL & CAN_INIT_BIT)) {
            SL_Log_Error(FUNC_ID_ST_CAN, ERR_TYPE_ENTRY_CON, 3u);
            retVal =  FALSE;
            return retVal;
        }
    }

It happily succeeds the call in 2.2.0, fails in 2.3.1

CCS 7.1

TMS570LC43 LaunchPad.

  • I'm attaching the project.

    You switch between SL versions by editing the variable SL_INSTALL_PATH in Properties -> Resource -> Linked Resources and do a rebuild.

    6087.TMS570LC43_example_SafetyLib.zip

  • Hello Jan,

    1. Enable CAN1 driver in HALCoGen, so HALCoGen can generate can.c
    2. make sure that the canInit() is called before doing CAN1 self test
  • This report is more a message to TI that the HALCoGen example that comes with HALCoGen 4.06.01 doesn't work  for Safety LIB  v2.3.1 ,
    while it works with 2.2.0

    It compiles ok for both version, but fails at SL runtime test SL_SelfTest_CAN()

    > 1. Enable CAN1 driver in HALCoGen, so HALCoGen can generate can.c

    I am using the example from HALCoGen e 4.06.01: example_SafetyLib.c
    All CANs are enabled in this example .

    >2. make sure that the canInit() is called before doing CAN1 self test

    Should that then not be part of the HALCoGen instructions or source code of that example?

    I have attached the project to my previous reply here. Can be replicated with a Hercules TMS570LC43 LaunchPad

  • Hello Jan,

    Thanks for clarification. I will do a quick test, and let you know my result soon.
  • Hello Jan,

    As I said, the CAN module is not initialized. The Init bit (bit 0) in CTL register is "1". 

    After I cleared this bit, the error will be gone.

     

  • Thank yuo, QJ. I'll test this ...
  • You are right. When I alter the control register like that, the tests succeed.

                canREG1->CTL &= ~(uint32)(0x00000041U);
                if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_1BIT, SL_DCAN1) == false)
                {
                    while(1);
                }
                if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_2BIT, SL_DCAN1) == false)
                {
                    while(1);
                }
                canREG2->CTL &= ~(uint32)(0x00000041U);
                if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_1BIT, SL_DCAN2) == false)
                {
                    while(1);
                }
                if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_2BIT, SL_DCAN2) == false)
                {
                    while(1);
                }
                canREG3->CTL &= ~(uint32)(0x00000041U);
                if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_1BIT, SL_DCAN3) == false)
                {
                    while(1);
                }
                if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_2BIT, SL_DCAN3) == false)
                {
                    while(1);
                }
                canREG4->CTL &= ~(uint32)(0x00000041U);
                if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_1BIT, SL_DCAN4) == false)
                {
                    while(1);
                }
                if(SL_SelfTest_CAN(CAN_ECC_TEST_MODE_2BIT, SL_DCAN4) == false)
                {
                    while(1);
                }
    

    Maybe something to correct in the next HALCoGen release?

  • Good job, Jan. Thanks for your good suggestions.