Page 1 of 1

delay or wait function

Posted: Sat 9. Apr 2022, 15:56
by ishara
Hi,
I'm wondering, how can we add a delay or wait function between messages in PCAN-Router FD. ( I need to add 20s or more delay here)

EX: I'm changing CAN ID 0X200 to 0X201 and change byte in 201 based on the value of 200.

Code: Select all

if ( RxMsg.id == 0x200  &&  RxMsg.msgtype == CAN_MSGTYPE_STANDARD)
{
        RxMsg.id = 0x201;
	RxMsg.msgtype =CAN_MSGTYPE_STANDARD;
	if(RxMsg.data8[0] == 0x10 ||RxMsg.data8[0] ==0x08)
	{
	        RxMsg.data8[0]=0x01;
                [u][b](how can I add 20s delay here?)[/b][/u]
        }
	else if(RxMsg.data8[0] == 0x18)
	{
	        RxMsg.data8[0]=0x21;
	}


Thanks

Re: delay or wait function

Posted: Mon 11. Apr 2022, 12:40
by M.Maidhof
Hi,

to implement a delay, you have to use a timer. Please see the 03_TIMER_IO example for more details on how to use a timer in PCAN-Router FD.

regards

Michael