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.

MCU-PLUS-SDK-AM263X: Sending Can Messages at a higher frequency

Part Number: MCU-PLUS-SDK-AM263X

Trying to send multiple CAN messages right after each other. But the code only sends the first message if there is no delay between sending messages.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void TorqueCalculationTask(void *pvParameters) {
uint64_t throttlePosition = 10;
uint64_t steeringPosition = 0;
CANMessage rrMessage;
CANMessage rlMessage;
CANMessage frMessage;
CANMessage flMessage;
while (1) {
// if (xSemaphoreTake(torqueValuesMutex, portMAX_DELAY)) {
// readThrottle(); // Read the throttle value at each cycle
throttlePosition = throttle_post_transfer;
steeringPosition = steering_post_transfer;
if (currentState == STATE_READY_TO_DRIVE && !brakePressed) {
calculateTorque(throttlePosition, torqueValues, steeringPosition);
createAMKCanMessage(0x1234, 1500, torqueValues[frontLeftInv], torqueValues[frontLeftInv+1], flMessage.message);
flMessage.id = 0x105; // Set the appropriate CAN ID
flMessage.message_length = 8;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Unless I add "vTaskDelay(pdMS_TO_TICKS(1));" after each transmission only the message with id 0x107 (the first one added to the queue) gets sent. Is there a way of sending message after one Tx is complete rather than having to add a manual time delay?

Expected frequency of messages is about 1500Hz so a 1 millisecond delay is not a viable option for me

  • Hello,

    Yes, you should check for transmission completion instead of adding delay.  Please explore MCAN_INTR_SRC_TX_FIFO_EMPTY before new transmission.

     

    Fullscreen
    1
    2
    #define MCAN_INTR_SRC_TX_FIFO_EMPTY (MCAN_IR_TFE_MASK)
    /**< Tx FIFO Empty interrupt */
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Best Regards,
    Gunjan