Dear all,
i'm using the S32K3X4EVB-T172 Evaluation Board (S32K344).
My application deals with two CAN Bus Interfaces using the MCAL API. Tx and Rx is configured as polling, therefore a periodic task (10 ms) is running, like that:
void canPollingTask(void *pvParameters)
{
const TickType_t xTickPeriod = pdMS_TO_TICKS(10);
TickType_t xLastWakeTime = xTaskGetTickCount();
for (;;)
{
Can_43_FLEXCAN_MainFunction_Write();
Can_43_FLEXCAN_MainFunction_Read();
vTaskDelayUntil(&xLastWakeTime, xTickPeriod*2);
}
}
Another Task is running (periodic at 100ms), which is writing CAN messages to the message buffers, like that:
void algorithmicTask(void *pvParameters)
{
const TickType_t xTickPeriod = pdMS_TO_TICKS(100);
TickType_t xLastWakeTime = xTaskGetTickCount();
for (;;)
{
Can_43_FLEXCAN_Write(CanHardwareObject_0_Tx_STD, &Can_PduInfo_0);
Can_43_FLEXCAN_Write(CanHardwareObject_0_Tx_STD, &Can_PduInfo_1);
Can_43_FLEXCAN_Write(CanHardwareObject_1_Tx_STD, &Can_PduInfo_2);
Can_43_FLEXCAN_Write(CanHardwareObject_1_Tx_STD, &Can_PduInfo_3);
vTaskDelayUntil(&xLastWakeTime, xTickPeriod*2);
}
}
If only one "Can_43_FLEXCAN_Write (doesn't matter which one)" is active, everything works fine. As soon as two or more "Can_43_FLEXCAN_Write (combination doesn't matter)" are active, "Can_43_FLEXCAN_Write" gives an error (indicating that a write to message buffer failed).
Can you please guide me, how to configure the message buffers in the right way? My understanding is that the "Message Buffer mechanism" does the buffering of the CAN messages and "Can_43_FLEXCAN_MainFunction_Write" transmit all messages stored inside message buffers.
I would like to configure each TransmitObject to have a message buffer with 16 messages of eight bytes payload. Unfortunately, i can't find the right settings inside Config Tool.
Would be great if you could guide me, how this to do or if you have an example project how to configre message buffers for CAN using the MCAL API.
Thanks a lot in advance for your support.
Best Regards
Dirk
解決済! 解決策の投稿を見る。
Hi,
"Can_43_FLEXCAN_MainFunction_Write" must be called if polling processing type is selected in the controller. It performs the polling of TX confirmation for configured HTHs, i.e. checks the message have been sent for used Tx MessageBuffer.
Can_43_FLEXCAN_Write writes desired PDU info into used TX MB, but first it checks if used HTH is really free (state is updated by Can_43_FLEXCAN_MainFunction_Write after message was transmitted)
So if you call Can_43_FLEXCAN_Write immediately with same HTH it returns CAN_BUSY.
You can add another HTHs in "CanHardwareObject" setting. Or you need to wait till previous transmission is finished. CanIf_TxConfirmation is also called upon successful transmission.
BR, Petr
Hi,
"Can_43_FLEXCAN_MainFunction_Write" must be called if polling processing type is selected in the controller. It performs the polling of TX confirmation for configured HTHs, i.e. checks the message have been sent for used Tx MessageBuffer.
Can_43_FLEXCAN_Write writes desired PDU info into used TX MB, but first it checks if used HTH is really free (state is updated by Can_43_FLEXCAN_MainFunction_Write after message was transmitted)
So if you call Can_43_FLEXCAN_Write immediately with same HTH it returns CAN_BUSY.
You can add another HTHs in "CanHardwareObject" setting. Or you need to wait till previous transmission is finished. CanIf_TxConfirmation is also called upon successful transmission.
BR, Petr