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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
2,190 Views
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

Labels (1)
Tags (1)
1 Solution
1,605 Views
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

View solution in original post

3 Replies
1,606 Views
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

1,273 Views
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 Kudos
1,605 Views
jinshuaixu
Contributor V

thank you for you helping.

0 Kudos