how to program to let Flexcan can continuous send data on s32ds.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

how to program to let Flexcan can continuous send data on s32ds.

跳至解决方案
3,437 次查看
jinshuaixu
Contributor V

       l set FLEXCAN baudrate is 250K.then if l send a frame,the needed time is calculate as folow:

      1000/(250*1000/8/16)=0.51 millisecond.

      Now, l do not want to send data through delay.l want to send data quilkly through read the status of register.such as follow(below code is error):

     while(1)

    {

        if (can0->milbox10->status==idle)

        {

             SendCANData(TX_MAILBOX, TX_MSG_ID, &ledRequested, 1UL);

        }

     }

     below is the mian file code ,l have upload the project.

     Thank you if you can help me.

 

int main(void)
{
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/

/* Do the initializations required for this application */
BoardInit();

GPIOInit();
FlexCANInit();

flexcan_data_info_t dataInfo =
{
.data_length = 1U,
.msg_id_type = FLEXCAN_MSG_ID_STD,
.enable_brs = true,
.fd_enable = true,
.fd_padding = 0U
};

/* Configure RX message buffer with index RX_MSG_ID and RX_MAILBOX */
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX, &dataInfo, RX_MSG_ID);

while(1)
{
SendCANData(TX_MAILBOX, TX_MSG_ID, &ledRequested, 1UL);
}

}

Original Attachment has been moved to: flexcan_encrypted.zip

标签 (1)
标记 (1)
1 解答
2,852 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

If using the same MB for transmissions, then you must be sure the MB is successfully transmitted before you are going to fill it again. So instead of delay you can use driver function

FLEXCAN_DRV_GetTransferStatus, for example as

 

/* Wait until the previous FlexCAN transmit is completed */

while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, TX_MAILBOX) == STATUS_BUSY);

BR, Petr

在原帖中查看解决方案

3 回复数
2,853 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

If using the same MB for transmissions, then you must be sure the MB is successfully transmitted before you are going to fill it again. So instead of delay you can use driver function

FLEXCAN_DRV_GetTransferStatus, for example as

 

/* Wait until the previous FlexCAN transmit is completed */

while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, TX_MAILBOX) == STATUS_BUSY);

BR, Petr

2,520 次查看
HancenChen
Contributor II

Hi PrteS,

If I use the freeRTOS and flexcan to send multi-frames, how can I make sure all the messages can be transmit ted normally? Also use while() statement to get the status?

0 项奖励
回复
2,852 次查看
jinshuaixu
Contributor V

thank you for you helping.

0 项奖励
回复