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.
Tool/software:
Customer experiencing serious configuration issue concerning the TI F28388D. In particular, the MCAN device controlled by the Connectivity Manager CPU (ARM), is exhibiting some troubling behavior.
They are trying to add CAN XCP capabilities to their embedded OS and using the included example (ex2) for CPU3 we have configured the MCAN for CAN-FD.
When they send a sequence of messages from a Peak PCAN-USB FD Adapter to the TI F28388D MCAN device we see consistent but random message losses. This behavior does not occur if they send and receive with 2 TI F28388D microcontrollers connected to each other, each equipped with a CAN Transceiver. The intended application is a Master (typically is not a TI CAN adapter) communicating with several TI F28388D Slave Units with TI MCAN on the CM sending telemetry data to the Master via CAN-XCP. Having this consistent message loss make it unusable.
Looking for guidance on debugging information to address this problem. The current Test Configuration in the lab is the following.
Hi Lawrence,
When they send a sequence of messages from a Peak PCAN-USB FD Adapter to the TI F28388D MCAN device we see consistent but random message losses
Do these messages have the same message ID? The received messages can be stored in RX buffers, or RX FIFOs. There are separate interrupts for RX buffer and RX FIFO. Have you enabled both the interrupts?
Can you share the MCAN configurations including the timing parameters in your project?
Hi QJ,
Will share MCAN code Debug report seperately
The Testing report is
Answer to your questions
Regards,
Lawrence
Hi Lawrence,
What is the cycle time for PCAN to transmit message repeatedly?
I am running the test with cycle time = 20ms, and haven't produced any issue.
My MCAN configuration is: 1mbps for ID, and 2Mbps for data
I use ex4 (receive) example with minor changes.
After I changed the cycle time to 2ms, and noticed that (10534-10494) =40 messages are lost (1st test), and (23612-23543)= 69 messages are lost. To void the message lost, the cycle time must be > 2ms.
Hi QJ,
The customer is running 1Mbit ID, and 1Mbit Data. The limitation is they are using SN65HVD230 in the setup, that my understanding does not support CAN FD higher speed.
Not sure if thats the issue or not but can you run at 1Mbit ID and 1Mbit Data?
Regards,
Lawrence
Hi QJ,
Update from customer:
>>> What is the cycle time for PCAN to transmit message repeatedly?
I have been trying from the range of 1ms to 10s as cycle time to send a sequence of messages.
>>> When running the test with cycle time = 20ms, and haven't produced any issue.
I got the similar result which is the total message count is good, but the received message content is not as expected.
From previous report, I sent an “sawtooth message” in a sequence (as figure below), in the cycle time of 10s. (I manually sent each message), the observation is the total message count is correct, however the message is not as the sent message.
In addition, could you use the MCAN ex1 or ex2 configuration to run the test? Since we are using the MCAN module on ARM core which we can directly try the configuration if yours is working.
Hi Lawrence,
It is the same for regular CAN communication. If the CAN node who is receiving CAN message takes long to read the message from the message RAM, the new received message will overwrite the previous message in message RAM which has not been read out.
This is my test with regular CAN. The Interrupt mode is used for receiving CAN message, and the RX ISR reads the message from message RAM without further process. There is no message lost if the cycle time is 1ms (minimum in PCAN GUI.
The number of msg transmitted (PCAN) = the number of msg received by F28 MCU (number in blue circle)
If I added a big delay in the RX ISR, most the packages are lost (7139 - 101). For not losing data, the application should empty the RX buffer/FIFO before the next message comes. About the TX node, the application should check if the previous message has been sent successfully before attempting a new one.
QJ,
Also the customer is saying they are manually communicating to F28388D so the cycle time is around 10 seconds. So something else is going on.
Regards,
Lawrence
Hi QJ,
Feedback from the customer in regards to your project:
Could you explain more about what the project is about? And it seems not what we want from the previous response.
I have the original ex4 project and modify to the setup , I can see it receive data and but I can see a lot of error generated in the interrupt function. I suspect the sampling point percentage is not right.
Could you provide the instruction of configuring the nominal and data segment of sampling in percentage?
Such as the code below, what is the sample point in percentage?
//
// Initialize bit timings.
// =40MHz/[(1+1)*(14+3+3)] = 1Mbps
bitTimes.nomRatePrescalar = 0x1U; // Nominal Baud Rate Pre-scaler
bitTimes.nomTimeSeg1 = 14U; // Nominal Time segment before SP
bitTimes.nomTimeSeg2 = 0x3U; // Nominal Time segment after SP
bitTimes.nomSynchJumpWidth = 0x3U; // Nominal SJW
// =40MHz/[(0+1)*(14+3+3)] = 1Mbps
bitTimes.dataRatePrescalar = 0x1U; // Data Baud Rate Pre-scaler
bitTimes.dataTimeSeg1 = 14U; // Data Time segment before SP
bitTimes.dataTimeSeg2 = 3U; // Data Time segment after SP
bitTimes.dataSynchJumpWidth = 3U; // Data SJW
//
Can you support a call with the customer as this getting very urgent.
Regards,
Lawrence
Hi Lawrence,
It is ex4 with minor changes.
1. Regular CAN is used: fdMore=0 and brsEnable=0
2. The PCAN keeping transmitting one message (ID=4) every 1ms.
3. F28 CAN is in interrupt mode, and is waiting for the message in a while() loop
4. The GPIO18 and GPIO19 are used for CAN
5. The 20MHz crystal is used
Hi QJ,
Any update on the code example for using a memory buffer in the ARM code for MCAN-Receive/ex2 example?
Regards,
Lawrence
Additional question from the customer:
======================
Thank you for the detailed information. I am already familiar with the filter and SFT setup in the example. What I am specifically looking for is clarification on the functions used within the interrupt function, as well as the sequence in which these functions should be called. This is critical for ensuring that our implementation is correct.
Could you please provide more insight into the function calls and their sequence within the interrupt context?
=====================
Regards,
Lawrence
Hi Lawrence,
The CM (Connectivity Manager, cortex-M4) supports 15 exceptions (reset, NMI, hard fault, MOU fault, bus fault, SVCall, SysTick, etc) and 64 external interrupts. All the external interrupts are configured via a peripheral known as the Nested Vectored Interrupt Controller (NVIC). The Exception Number for external interrupts starts at 16. Please refer to Table 41-5. NVIC Interrupt Mapping in device TRM (Page 4230):
TMS320F2838x Real-Time Microcontrollers With Connectivity Manager TRM (Rev. F)
The NVIC has sets of registers for configuring the “external” interrupt lines. Please refer to 41.12.9 NVIC Registers in TRM (Page 4375). The MCAN core has two interrupt lines, and provided two interrupt requests (MCAN_INT0, and MCAN_INT1). The interrupt numbers for MCAN in NVIC table are 16 (MCAN_INT0) and 17 (MCAN_INT1).
In the CM MCAN (ex2) example, the ISR for MCAN_INT0 is MCANIntr0ISR, and MCANIntr1ISR for MCAN_INT1. The interrupt line 1 is used for all the MCAN RX interrupts (MCANIntr1ISR(void)), and the interrupt line 0 is used for all the MCAN TX interrupts.(MCANIntr0ISR(void)).
All the 30 MCAN interrupt sources (RX buffer is highlighted) are enabled:
Hi QJ,
From Customer:
=============
Thank you for the detailed insights into the interrupts and exceptions. However, to ensure we can implement the MCAN code correctly and efficiently, we would feel much more confident if we had a working reference example that specifically handles interrupt functions within the interrupt context.
This example is particularly critical for us as many future products will rely on this MCAN code. Having a clear reference will not only help us but also ensure that our implementation is robust and reliable.
Could you please provide an example that includes the sequence of function calls within the interrupt service routines (ISR), particularly focusing on how to handle interrupts within those functions? Your support in providing this would be greatly appreciated.
Thank you in advance for your continued assistance
=============
Regards,
Lawrence
Hi Lawrence,
Please find the attached example. The coming messages with standard ID are stored in RX buffer, and the messages with extended ID are stored in FIFO 1. Interrupt 1 is used for RX.
The "mcan_config_c28x" has to be executed in CPU1 first. It initialize the GPIO and clock for M4.
Hi QJ,
Feedback from customer:
=============
Thank you for sharing the provided example. Upon reviewing it, I noticed that, aside from changes in the bit timing configuration, there don't appear to be any other updates compared to the official mcan_ex2_external_loopback example.
What I specifically need help with is understanding which functions I should call within the receive ISR and the correct sequence for handling incoming messages when using the memory buffer to receive. This information is crucial for us to ensure that the ISR behaves correctly in our application.
============
Any guidance on this?
Regards,
Lawrence
Hi Lawrence,
As mentioned before, the MCAN core has 2 interrupt lines and 20 interrupt sources. Each source can be configured to drive one of the two interrupt lines. For example , using INT line 0 for TX interrupt sources and INT line 1 for RX interrupt sources. The bits of MCAN_IR registers show the interrupt flag which is set when the corresponding interrupt occurs.
The received message can be stored in RX buffers, or one of the two FIFOs (FIFO 0 or FIFO 1). MCAN module has two sets of acceptance filters, one for standard IDs and one for extended IDs. If filter matches, the message is stored in RX buffer if SFEC[2:0] =0x7 or EFEC[2:0]=0x7 (refer to MSG ID filter element field description).
1. After a received message has been accepted by a filter element, the message is stored into the RX buffer in the message RAM. The flag MCAN_IR.DRX is set.
MCAN_getIntrStatus(...)
MCAN_clearIntrStatus(..)
2. After the last word of a matching received message has been written to the Message RAM, the respective New Data flag in register MCAN_NDAT1 or MCAN_NDAT2 is set.
MCAN_getNewDataStatus(..)
As long as the New Data flag is set, the respective Rx Buffer is locked against updates from received matching frames. The New Data flags must be reset by the Host CPU by writing a 1 to the respective bit position.
MCAN_clearNewDataStatus(..)
3. Scan the newData register and read appropriate mailbox if any message is received.
Mcan_ReadMsgRam(...)
4. Clear interrupt in EOI register.
MCAN_ClearLineInterrupt()
5. The PIEACK bit for the interrupt group must be cleared manually. If the PIEACK bit is not cleared, the CPU does not receive any further interrupts from that group.
McAN_ClearACKGroup()
Thank you for your detailed explanation regarding the interrupt handling sequence for the MCAN core. I have a few follow-up points and requests:
1. The setup you provided seems to focus on the handling process for CPU1 ( references to the mcan_ex4_receive example). However, we need the version that operates on the ARM core. Could you please provide that?
2. My main/original concern is with the functions MCAN_ClearLineInterrupt() and MCAN_ClearACKGroup(), which you mentioned "must be cleared manually." These functions do not appear to exist in the MCAN library, and this could present a major issue for our program's implementation. Could you clarify if these functions are part of a different module or if there are alternative functions we should be using to manually clear interrupts, especially in the context of the ARM core?
3. Could you please provide a working example that demonstrates receiving messages using the memory buffer and the corresponding ISR function calls? A brief explanation of the sequence would also be greatly appreciated, especially how it should be implemented for our scenario.
Hi QJ,
Any update? Customer requesting a meeting to discuss this need.
Regards,
Lawrence
Hi Lawrence,
McAN_ClearACKGroup() should be Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9) which is API of C2000ware.
MCAN_ClearLineInterrupt() is MCAN_clearInterrupt() in C2000ware
The MCAN interrupts should be handled in the same procedure for C28 and CM.For CM, the Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9) is not needed.
The PIEACK bit for the interrupt group must be cleared manually in user code. This is normally done at the end of the ISR. If the PIEACK bit is not cleared, the CPU does not receive any further interrupts from that group. This does not apply to the Timer1 and Timer2 interrupts, which do not go through the PIE.
For C28x, the interrupt path is divided into: peripheral, PIE, and C28x CPU
For CM, the interrupt path is: peripheral, NVIC, and Cortex-M4 MCU.The NVIC multiplexes interrupts from various peripherals into the CM interrupt lines.
MCAN has two interrupt lines, and 30 internal interrupt sources. Each interrupt source can be configured to drive one of the two interrupt lines. The interrupts are level sensitive interrupt.
When CM enters the ISR, the state of the interrupt is changed from pending to active. For a level sensitive interrupt, when CM returns from the ISR, the NVIC samples the interrupt signal. If the signal is asserted, the state of the interrupt changes to pending, which might cause the CM to immediately re-enter the ISR. So we need to clear the interrupt status and clear the line interrupt.
QJ,
Customer still need some clarification regarding your latest response:
============================
You mentioned,
>>>
"When CM enters the ISR, the state of the interrupt is changed from pending to active. For a level-sensitive interrupt, when CM returns from the ISR, the NVIC samples the interrupt signal. If the signal is asserted, the state of the interrupt changes to pending, which might cause the CM to immediately re-enter the ISR. So we need to clear the interrupt status and clear the line interrupt."
I would greatly appreciate it if you could provide a complete working example demonstrating the correct handling of receiving messages using the memory buffer, including the sequence of ISR function calls, particularly in relation to clearing the interrupt status and line interrupt as mentioned. A step-by-step explanation would be very helpful to ensure proper implementation in our scenario.
We have a session scheduled for tomorrow morning, and hopefully, we can use that opportunity to clarify any confusion. As this has now been going back and forth for 4 weeks, a clear example would help us finally move forward.
===================
Regards,
Lawrence
Hi Lawrence,
Nice having a meeting with customer. Attached is the example used in the meeting: