CAN Message Buffers Configuration

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

CAN Message Buffers Configuration

ソリューションへジャンプ
848件の閲覧回数
DirkG
Contributor III

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 

0 件の賞賛
返信
1 解決策
814件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

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

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
815件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信