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.

SAFETI-HALCOGEN-CSP: CAN1_UT_07:4 - Test canGetData API with data loss condition - fails

Part Number: SAFETI-HALCOGEN-CSP
Other Parts Discussed in Thread: HALCOGEN,

Tool/software:

Dear,

I cannot get one of the HALCoGen unit tests to pass. Happens on all three CAN interfaces. Failing test case is CAN1_UT_07:4 - Test canGetData API with data loss condition.

I have made sure to configure the message boxes and interrupts according to the test sequence requirements stated in the xlsx file:

1) Enable All CAN Interrupts in VIM Tab
2) Message 1,2,3,4,5,6 are activated
3) Message 1 config - TX, DLC = 8, No Interrupt, ID = 1
4) Message 2 config - RX, DLC = 8,  Low Priority Interrupt Enabled, ID = 1
5) Message 3 config - TX, DLC = 8, No Interrupt, ID = 3
6) Message 4 config - RX, DLC = 8,   High Priority Interrupt Enabled, ID = 3
7) Message 5 config - TX, DLC = 8, No Interrupt, ID = 5, Enable RTR
8) Message 6 config - RX, DLC = 8,  High Priority Interrupt Enabled, ID = 5.

I have further made sure that all other message boxes are deactivated such that the test message does not get stolen by some other message box.

The test case startup code looks as follows:

canTransmit(canREG1, canMESSAGE_BOX3, tx_data);
while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX4));
canTransmit(canREG1, canMESSAGE_BOX3, tx_data);

So the code sends to message box 4, waits for message arrival but does not collect the data and then sends another message to force a message lost indication. Apparently the message lost indication does not get set and I am out of ideas why. All other test cases pass just fine but this one fails for every CAN interface.

  • Hi Julia,

    If the message with the same ID is received, the unread message in the mailbox will be overwritten. Since the RX interrupt is enabled, does the CAN ISR move the message from mailbox 4 to data register? 

  • No, the ISR in notification.c is blank when it is generated by HALCoGen and I do not see the xlsx file add ISR implementations either. What I do to use the CSP: I copy over the hcg and dil files from my application, change the configuration for the message boxes and interrupts and disable the CCM and CPU selftest options to allow for debugger attachment. Then I generate the code and run the tests. 

    Everything works just fine but this one test case does not. I know by now that there are inter-dependencies in the test sequences such that I should not disable test cases up top because it can fail test cases down below. But for this test case failure, I had all test cases enabled.

  • Hi Julian,

    If canMessageNotification() is empty, the CPU doesn't read the message from the message RAM, and the NewDat bit is not cleared. If a new message comes, the MsgLst will be set to indicate the previous message is lost.

    Did you check if NewDat is set before re-transmit the message?

  • Yes, the test case already does that with the while statement shown above. it calls canIsRxMessageArrived to check newdat until it is set. I will now add a printing that lists all message boxes with that flag set after the re-transmission to find out if some other box stole it and report back.

  • Ok, so my printing experiment revealed a newdat indication for message box 4 and 7. So even though mb7 is left in default configuration, it will steal the retransmission. I made another test where I configured mb7 explicitly to be RX and enabled it, but since its configured id of 7 does not match, it will not take the retransmission. So far so good. Unfortunately the test does now only show newdat for mb4 (expected), but it still fails because canGetData returns 1 instead of the expected 3 (msglost).

    ********************************************************************************
    *
    * Executing Existing Test Case 19 in Sequence CAN1_UT
    * File : C:\test\unit\halcogen\source\can.c
    * Procedure : canGetData
    *
    ********************************************************************************
    newdat in mb 4                                           <------- The added printing, now ok
    Input for node = (canBASE_t*) canREG1
    Input for messageBox = (uint32) canMESSAGE_BOX4
    Input for data = (uint8* const) rx_data

    Call canGetData
    No exception raised
    Output for = 1 FAIL: expecting (uint32) 3   <--------- Still no msglost flag
    ********************************************************************************

    So I am naturally wondering:

    • Why does mb7 take the message when it is not configured? I have checked the sample project in the CSP and the mb7 config is exactly the same (HALCoGen default for every unused mb).
    • Why do I still not get a msglost indication even though I have made sure that the message does not end up in any other mb?

    The last point is kind of surprising to me because I thought mb7 stealing the message was the cause in the first place.

  • Another data point: I have tried to disable IRQ globally at the beginning of the testcase and reenabled it at the end. This had no effect. So it definetly is not an ISR clearing newdat such that msglost would not be set. I am getting the feeling that, for whatever reason, the CAN controller indeed does not set msglost when it has a new frame and it sees newdat already set. I do not assume this to be a general problem but I am out of ideas what could lead to this in my case.

  • Hi Julian,

    I run some CAN TX/RX test this morning, got the same issue: MsgLst bit is not set. I don't see the newDat bit in message object in message RAM. 

  • So you do not see newDat at all? I do see newDat since the testcase waits for it and when I print, I check it using the driver API. Only msglost never happens.

    So what could be the cause here? My thoughts:

    • A general problem in CAN IP highly unlikely given design age
    • A problem with the internal loopback would also be surprising as it would have been revealed by the creators of the CSP testcases
    • Maybe some HALCoGen generated code has changed between initial CSP release and today and that change reveals the issue?

    How do we proceed? Any ideas what we could try? I already disabled the other two CAN drivers to rule out some „cross-pollination“ in the generated code. Had no effect.

    In my specific case I can disable the failing testcase and provide a lengthy justification that the msglost indication has no safety impact. But I would rather get to the bottom of this.

  • So you do not see newDat at all?

    I don't see newDat in message object in message RAM. I read the message manually on CCS memory browser (direct RAM access). 

    How do we proceed? Any ideas what we could try?

    Actually many customers use HalCoGen CSP for peripheral unit test, and I didn't get report of this kind of issue before. I am wondering if we missed something in config.

  • I have tried a new and vanlla HALCoGen configuration for the 1224PGE by now. I only changed the required VIM and CAN config as per requirement in the xlsx. The problem persists. No msglost is set. Ideas what else I can try?

  • Hi Julian,

    The test report in the folder of "..\SafeTI-HALCoGen-CSP\TMS570LS12x_11x_v04.07.01\HALCoGen\TMS570LS12x\CSP\Test\Reports\Regression Reports' shows that the test passed:

    CAN1_UT.thr.htm

  • Yes, I am aware. But I cannot reproduce it, even with a vanilla HALCoGen config. Just to clarify, the mere interrupt arrival with an empty handler will not clear the newDat, only resetting it (e.g. using canGetData) will. Correct? Thats how I understand the test case. How can my vanilla config diverge from the one used by the CSP creators? I will do a diff on the sample dil files and see if that reveals anything. But I am not optimistic to find anything and really wonder whats going on here. Particularly since you were able to reproduce the issue on your end.

  • Hi Julian,

    I did more test on L12x launchpad. I am not able to make the test pass.

  • Hi Julian,

    I tested with a different HW setup: loop CAN1 to CAN2. CAN1 transmits message and CAN2 receive message. The MSGLST is not set either. I noticed that the data of 2nd transfer is not copied to the CAN2 message RAM. It is ignored. 

  • Thank you for checking and sorry for coming back late. I also tried a setup were I just had an eval board, an external CAN interface, a minimal configuration and program and the results were consistent with your findings. I could not convince the CAN IP to raise the MsgLost indication.

    If you have any suggestions what else to try, I am here for it. Best regards

  • Without wanting to distract from the topic, are there any confirmation that the MsgLst register can be set to 1 on the TMS570, even outside of this test? I found this thread because I am encountering a similar issue on a TMS570LC4357ZWT (wanted to test for missed messages, could not make it happen).

  • Dear,

    feel very welcome to add to this thread. 

    While I cannot provide a different answer than „TI staff had the test passing when CSP was created“, these are factors I plan to look into next:

    - HALCoGen version: Maybe a bug was introduced between the version used when creating the CSP and the latest one

    - Role of ext. IDs: Just a shot in the dark, check if changing up ID scheme changes situation

    - Role of HALCoGen default config: Maybe if I activate all other mailboxes and configuring them for TX, CAN IP will decide it is out of options for the second frame and finally raise MsgLost

    - Role of enabled interrupt: Maybe disabling all interrupts might change CAN IP behavior when 2nd frame comes in

    Will report back when I learn something.

  • Hi Julian,

    Thank you to try different configurations. But I don't have other version of HalCoGen. 

  • I am using HALCoGen 04.07.01, my CAN message ID is 0x199. I am configuring mailboxes without using HALCoGen's drivers, although I use them to initialize the CAN devices. I've not tried the test suite to ensure all features work (I'll admit, I just assume they do). I'm working on porting a client's application. I have configured a single mailbox for this particular ID, and my current test is to read 1 message every 100ms, turning on LEDs depending on whether it's ready to be read, missing, or if a message was lost (MsgLst bit of the mailbox's MCTL register).

    There are no interrupts involved, other than FreeRTOS's tick. I use a polling method.

    Using a separate device, I send CAN messages a different frequencies. My current little test involve echoing data back with different message IDs, it all seems to work, except for MsgLst. Even sending 1 message every 1ms, I fail to trigger the MsgLst bit. I have yet to check if an overriding of the mailbox's data happens, though. I was hoping to find that I forgot to set some register allowing that overriding to happen and that was why it could not get the MsgLst signal, but no such luck so far (investigating whether I'm failing to account for MCTL's EoB bit at the moment).

    Edit:
    I had a suspicion it might be linked to the buffer system and indeed, I'm not setting the EoB bit of the mailbox. I am trying to set it, but apparently failing to. From what I understand, this would explain my issue with MsgLst (EoB kept at 0 prevents overriding). Now investigating why my EoB bit isn't being set despite a reset of MsgVal before starting to configure the mailbox. Hopefully it's related to your own issue.

    Second edit: Made a mistake with the address of the register (oops). Setting EoB properly fixes my MsgLst issue. Slight smile

  • Hi William, 

    Wonderful! Thank you! Setting the EoB bit solved the problem. 

    1. Enable the EoB of the receiving message object, the generate code

    2. The main function to check the MsgLst

    TMS570LC43x_DCAN_MsgLst.zip

  • Yes, that was it for me, too. Thank you so much. TRM is also clear on that point when showcasing how to set up a single messagebox for receival.

  • Hi,

    yes, test is passing now. 

    This was quite a head-scratcher. I feel either the CSP testcase instruction for the CAN unit tests should have included this in its messagebox setup instructions or, maybe even better, HALCoGen should have that bit set as a default value.

    Thank you for your support.

    My best regards

  • Hi Julian,

    I will add a note and a FAQ to stress this issue.