LPC1113 timer0 not working

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

LPC1113 timer0 not working

765 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cararra on Wed Nov 21 07:59:53 MST 2012
Hi,

I got RS232 all working with interrupt driven code.
But this timer code just does not seem to work.
The variable  Timer0_M0_Counter is always 0.
If I put a break in the middle of the code it never reaches the interrupt handler.

Any ideas what I am missing / doing wrong? :confused:


// LPC1113 code

int Timer0_M0_Counter = 0;

void TIMER16_0_IRQHandler(void)    // This is being overridden from its definition in cr_startup_lpc11.c
{[INDENT]         if(LPC_TMR16B0->IR & (0x1<<0))        // Check for Match Register0 for interrupt on timer0
{
[/INDENT][INDENT][INDENT]       LPC_TMR16B0->IR = 0x1<<0;    // Clear M0 interrupt flag of timer0
[/INDENT][/INDENT][INDENT][INDENT]       Timer0_M0_Counter++;        // general time keeping counter that ticks every millisecond
[/INDENT][/INDENT][INDENT]         }
[/INDENT]}

main()
{[INDENT]    ..
[/INDENT][INDENT]    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6 | 1<<7);     // Enable AHB clock to the GPIO (bit 6), and t Timer0 (bit7).
[/INDENT][INDENT]    LPC_TMR16B0->MR0 = 1000;             // Set up 1 mS interval
[/INDENT][INDENT]    NVIC_EnableIRQ(TIMER_16_0_IRQn);        // This enables the timer interrupts
[/INDENT][INDENT]    LPC_TMR16B0->TCR = 1;                // enable timer0
[/INDENT][INDENT]    ..
[/INDENT]}
0 Kudos
Reply
2 Replies

750 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Nov 21 09:19:27 MST 2012
Next problem:
LPC_TMR16B0->MR0 = 1000;             // Set up[COLOR=Red] 1 mS[/COLOR] interval
0 Kudos
Reply

750 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cararra on Wed Nov 21 09:01:34 MST 2012
[FONT=arial]Solved! :D

Problem was missing line:
[/FONT][INDENT][FONT=arial]LPC_TMR16B0->MCR = (0x3<<0);    // Generate interrupt on MR0 match + reset TC on MR0 match [/FONT]
[/INDENT]This had to follow after the line LPC_TMR16B0->MR0 = 1000;             // Set up 1 mS interval.
You can guess what happened - MR0 and MRC looks so similar so I went past it many times!! :eek:
0 Kudos
Reply