low-level timer interrupt

24 Dec 2011

I would like to setup a timer and I need to have full control. For some reason I don't get it working and I think it has to do with some mbed library changes.

When I take the example from: http://mbed.org/forum/mbed/topic/480/?page=1#comment-2426

It works with the mbed library v19 but fails to trigger the ISR with v31.

Can anybody help me get this working with the latest mbed lib and explain what changed. I notices a ton of new subdirs (which also makes it hard to compare the changes for me) LPC1768/ARM; LPC1768/GCC_CR; LPC1768/GCC_CS; LPC1768/uARM; LPC1768/GCC_ARM

24 Dec 2011

I tried out different mbed versions (by importing with http://mbed.org/projects/libraries/svn/mbed/trunk@20). Already v20 does not work anymore with the example.

I looked at the diffs but cannot pinpoint the reason: http://mbed.org/projects/libraries/changeset?old_path=%2Fmbed%2Ftrunk&old=19&new_path=%2Fmbed%2Ftrunk&new=20#file0

Help appreciated,

24 Dec 2011

minimal example that works with the mbed lib v19 but not with any newer ones:

#include "mbed.h"

DigitalOut led2(LED2);


void myIRQ() {
    led2 = !led2;
    LPC_TIM0->IR |= 1 << 0;
}


int main() {
    // LPC_SC->PCONP |= 1<<1; // Timer0 Power On
    LPC_TIM0->MR0 = 3600000;  // Match count for 150ms
    LPC_TIM0->MCR = 3;     // Interrupt and Reset on Match
    LPC_TIM0->TCR = 1;     // Enable Timer0
    NVIC_SetVector(TIMER0_IRQn,(uint32_t)&myIRQ);
    NVIC_EnableIRQ(TIMER0_IRQn);

    while (1) {}
}
24 Dec 2011

try this:

void myIRQ() {
    LPC_TIM0->IR |= 1 << 0;
    led2 = !led2;
}
24 Dec 2011

Thanks, Rene!

I've just come to the same fix. This solves the issue. More info here: http://www.keil.com/forum/18951/

15 Feb 2016

Thank you, it was helpful.