Sending Multiple CAN ID message at different rates

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

Sending Multiple CAN ID message at different rates

286 Views
KKumar
Contributor II

Hi NXP,

I need to send multiple CAN message at different rate from only one CAN MBs

Let say.

CAN ID 0x30   : at 500 ms

CAN ID 0x31   :  at 500 ms

CAN ID 0x32   : at 1000 ms

CAN ID 0x33   :  at 1000 ms

CAN ID 0x34  : at 1000 ms

CAN ID 0x35  : at 100 ms

CAN ID 0x36  : at 500 ms

CAN ID 0x37  : at 100 ms

Suggest some logic to send these CAN message at their cycle time.

 

 

 

0 Kudos
Reply
1 Reply

253 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@KKumar

You need to set a timer, set the interrupt time of this timer to 100ms, and set multiple event stamp flags, for example:

uint8_t flag_100ms,flag_500ms,flag_1000ms = 0;

/*100ms interrupt handler*/
void timer_interrupt_handler()
{
 flag_100ms++;
 flag_500ms++;
 flag_1000ms++;
}

main()
{
 while(1)
{
  if(flag_100ms >= 1)
{
flag_100ms = 0;
do something....
};

if(flag_500ms>=5)
{
flag_500ms = 0;
do something....
}

}

}
0 Kudos
Reply