This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with Timer0 interrupt

Hi all,
I'm a newbie on LPC1768 and copy the following program from a site - the program is to blink an LED using timer interrupt 0. The program is as follow

#include "LPC17xx.h"

int main (void)
{ LPC_SC->PCONP |= 1 << 1; // Power up Timer 0 LPC_SC->PCLKSEL0 |= 1 << 2;

LPC_TIM0->MR0 = 1 << 23; // Give a value suitable for the LED blinking

LPC_TIM0->MCR |= 1 << 0; // Interrupt on Match 0 compare

LPC_TIM0->MCR |= 1 << 1; // Reset timer on Match 0

LPC_TIM0->TCR |= 1 << 1; // Manually Reset Timer 0 (forced)

LPC_TIM0->TCR &= ~(1 << 1); // Stop resetting the timer

LPC_TIM0->TCR |= 1 << 0; // Start timer

LPC_SC->PCONP |= ( 1 << 15 ); // Power up GPIO

LPC_GPIO1->FIODIR |= 1 << 29; // Put P1.29 into output mode

while (1); }

void TIM0_IRQHandler(void)
{ if ( (LPC_TIM0->IR & 0x01) == 0x01 ) // if MR0 interrupt

{ LPC_TIM0->IR |= 1 << 0; // Clear MR0 interrupt flag

LPC_GPIO1->FIOPIN ^= 1 << 29; // Toggle the LED }
}

But when i debug the program and perform a single step debugging the led is not toggle(P1.29)-
When TC=MR0 (in debug mode) it jump into startup_MPS_CMO.s and hang at the position as shown (->>>>).
I'm using Keil uvsion with startup_MPS_CM0.s. May i know what's wrong with my program? THANK YOU.

Default_Handler PROC

EXPORT WDT_IRQHandler [WEAK]
EXPORT RTC_IRQHandler [WEAK]
EXPORT TIM0_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT MCIA_IRQHandler [WEAK]
EXPORT MCIB_IRQHandler [WEAK]
EXPORT UART0_IRQHandler [WEAK]
EXPORT UART1_IRQHandler [WEAK]
EXPORT UART2_IRQHandler [WEAK]
EXPORT UART3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT AACI_IRQHandler [WEAK]
EXPORT CLCD_IRQHandler [WEAK]
EXPORT ENET_IRQHandler [WEAK]
EXPORT USBDC_IRQHandler [WEAK]
EXPORT USBHC_IRQHandler [WEAK]
EXPORT CHLCD_IRQHandler [WEAK]
EXPORT FLEXRAY_IRQHandler [WEAK]
EXPORT CAN_IRQHandler [WEAK]
EXPORT LIN_IRQHandler [WEAK]
EXPORT I2C_IRQHandler [WEAK]
EXPORT CPU_CLCD_IRQHandler [WEAK]
EXPORT SPI_IRQHandler [WEAK]

WDT_IRQHandler
RTC_IRQHandler
TIM0_IRQHandler
TIM2_IRQHandler
MCIA_IRQHandler
MCIB_IRQHandler
UART0_IRQHandler
UART1_IRQHandler
UART2_IRQHandler
UART3_IRQHandler
UART4_IRQHandler
AACI_IRQHandler
CLCD_IRQHandler
ENET_IRQHandler
USBDC_IRQHandler
USBHC_IRQHandler
CHLCD_IRQHandler
FLEXRAY_IRQHandler
CAN_IRQHandler
LIN_IRQHandler
I2C_IRQHandler
CPU_CLCD_IRQHandler
SPI_IRQHandler

->>>>> B .

ENDP

ALIGN

0