bad Ticker performance on LPC1549

12 Jan 2016

I use a Ticker for the project to sample an IR signal. Sampling frequency is 15 kHz, Calling the ISR works on a LPC1347 or LPC4088 well, but on the LPC1549 there is a performance problem. I've checked the mbed lib and found a (significant?) difference in the us_ticker.c/us_ticker_set_interrupt() procedure:

on the LPC1347, this is just setting a register:


void us_ticker_set_interrupt(timestamp_t timestamp) {
    // set match value
    US_TICKER_TIMER->MR0 = (uint32_t)timestamp;
    // enable match interrupt

on the LPC1549, this is a multiply and bit operation:


void us_ticker_set_interrupt(timestamp_t timestamp) {
	uint64_t temp = ((uint64_t)timestamp * (SystemCoreClock/1000000));
    LPC_RIT->COMPVAL = (temp & 0xFFFFFFFFL);
    LPC_RIT->COMPVAL_H = ((temp >> 32)& 0x0000FFFFL);

As far as I understand the code, the us_ticker_irqhandler calls this function every _1_µs_, so every more cycle in this irq will have a deep impact on the overall performance. Can anyone confirm this problem? I found already an issue with the 72 min overflow, also caused by using the RIT. Isn't ist better to use a standard 32 bit timer for the ticker implementation?

Edit: Oo oh, I'm blind. The ISR is not called every usec, the timestamp is the next compare match. But what could be the performance problem?

12 Jan 2016

The LPC1549 is an M3 right? Code could be more efficient, but in principle it shouldn't take alot of time. The 72 min overflow is supposed to happen (unless it doesn't overflow properly, then you can ignore this part). And I guess there is no 32-bit timer available (but not sure).

The irq handler is only called when it is required by the way, not every microsecond.

12 Jan 2016

Thanks. Yes, I saw already that my microsecond idea was wrong. The performance measurement in the linked sample prints 3 / 9 us for avg / max time in ISR for the 1347, for the (faster) 4088 it is 2 / 5 us. But with the 1549 the avg is 35 us, the program runs only when I reduce Int frequency to 5 kHz. Will later try to debug the offline project in LPCXpresso.

Edit: Have exported to LPCXpresso v8.0.0, even the debug version runs fine with 15 kHz Int frequency: max 13 avg 6 µs. Tried again the same code from the online compiler: does not work. Interrupt frequency down to 6 kHz, I get outputs: max 39, avg. 33 µs. So in this case maybe there is something wrong with the online compiler settings.

Please log in to post a reply.