8 years, 4 months ago.

Different Implemenation of us_ticker_set_interrupt in us_ticker.c

Actually i am using 2 tickers on a LPC824. On is running alll the time every 20ms, the period of the second one is changed inside its callback funktion using again the attach function with a different time (between 50ms and 3s)

If only the 20ms ticker is running there is no problem, but if i start the second one with the changig period, sporadically the ticker fires mucht to late 10-50seconds later. I figured out that this happens because an invalid timestamp for the us timer is generated in case the new timestamp is already in the past, actually i don't know why it is in the past.

Now i saw that in some implementations this case is handled like this:

int delta = (int)(timestamp - us_ticker_read()); if (delta <= 0) { This event was in the past: us_ticker_irq_handler(); return; }

but in the LPC824 implementation or other nxp chips there is no such handling:

LPC_MRT->INTVAL1 = (((timestamp - us_ticker_read()) * MRT_Clock_MHz) | 0x80000000UL);

Enable interrupt LPC_MRT->CTRL1 |= 1;

Is there a reason for this?

Anybody an idea of how it is possible that i get timestamps which are already in the past?

Thx

Question relating to:

Be the first to answer this question.