EmbeddedRelated.com
Forums

Timer Interrupt problem in LPC2106

Started by rockraj_2003 May 4, 2005

Hello Friends,

Interrupt problem in LPC2106.
I am using IAR EMBEDDED WORKBENCH.The Timer Interrupt is not
responding.

Simply for Half an hour it typing only SET.
Its not typing Timer Interrupted.
I can't able to find any mistake.
When i worked with the Simulator it works fine. Its correctly
entering data into the reg. This is the code.
#pragma language=extended
#include "ma_tgt.h"
#include "ma_sfr.h"
#include "iolpc210x.h"
#include <inarm.h>
#include "ma_scb.h"
#include "ma_uart0.h"
#include "ma_pcb.h"
#include "stdio.h"
#include "timer.h"
#include "LPC21XX.H"

extern void init_timer (void);

static void DefDummyInterrupt()
{}

__irq __arm void TIMER0 (void) {

MA_PutString_UART0("Timer Interrupted");
T0IR = 1;
VICVectAddr = 0;
} void init_timer (void)
{
MEMMAP = 2;
VICProtection = 0;
VICIntEnClear = 0xffffffff;
VICDefVectAddr = (unsigned int)&DefDummyInterrupt;
T0TCR = 0;
T0PC = 0;
T0CCR = 0;
T0EMR = 0;
T0MR0 = 0xFFFF;
T0MCR = 3;
VICVectAddr0 = (unsigned int)TIMER0;
VICVectCntl0 = 0x20 | 4;
VICIntEnable = 0x00000010;
T0TCR = 1;
}

void main(void)
{
MA_Reset_SCB();
MA_Reset_PCB();
MA_Init_UART0();
MA_Reset_UART0();
init_timer();
for(;;)
{
MA_PutChar_UART0(0xD);
MA_PutChar_UART0(0xA);
MA_PutChar_UART0(0xD);
MA_PutChar_UART0(0xA);
MA_PutString_UART0("SET");
MA_PutChar_UART0(0xD);
MA_PutChar_UART0(0xA);
for(S8 i=0;i<10;i++)
Sleep(135000);
}

}

Kindly clarify my doubt.

with regards,
Raj


An Engineer's Guide to the LPC2100 Series

Raj,

Attached is a working code from ARM_UCOS port for
LPC210x. The main difference is that this does not use
the VIC, instead software distribution from the IRQ
handler. In your case the Timer itself is not firing,
hence this shouldnt matter.

Cheers,
-Mike.

static void __vT0Interrupt()
{
rT0IR = BIT_IR_MR0;

OSTimeTick();
}

#define T0_DIV 3
void FRMWRK_vStartTicker(U32 wTicksPerSec)
{
// setup Timer 1 to count forever
rT0TCR = BIT_TCR_RESET; // reset &
disable timer 0
rT0PR = T0_DIV-1; // set the
prescale divider
rT0MR0 = (PCLK/T0_DIV)/wTicksPerSec;// set the
match register 0
rT0MCR = (BIT_MCR_MR0_I|BIT_MCR_MR0_R);
rT0CCR = 0; // disable
compare registers
rT0EMR = 0; // disable
external match register

pISR_TIMER0 = (U32)__vT0Interrupt;
INT_ENABLE(IRQ, BIT_TIMER0);

rT0TCR = BIT_TCR_ENABLE; // enable
timer 0
} --- rockraj_2003 <rockraj_2003@rock...> wrote:
>
> Hello Friends,
>
> Interrupt problem in LPC2106.
> I am using IAR EMBEDDED WORKBENCH.The Timer
> Interrupt is not
> responding.
>
> Simply for Half an hour it typing only SET.
> Its not typing Timer Interrupted.
> I can't able to find any mistake.
> When i worked with the Simulator it works fine. Its
> correctly
> entering data into the reg. > This is the code.
> #pragma language=extended
> #include "ma_tgt.h"
> #include "ma_sfr.h"
> #include "iolpc210x.h"
> #include <inarm.h>
> #include "ma_scb.h"
> #include "ma_uart0.h"
> #include "ma_pcb.h"
> #include "stdio.h"
> #include "timer.h"
> #include "LPC21XX.H"
>
> extern void init_timer (void);
>
> static void DefDummyInterrupt()
> {}
>
> __irq __arm void TIMER0 (void) {
>
> MA_PutString_UART0("Timer Interrupted");
> T0IR = 1;
> VICVectAddr = 0;
> } > void init_timer (void)
> {
> MEMMAP = 2;
> VICProtection = 0;
> VICIntEnClear = 0xffffffff;
> VICDefVectAddr = (unsigned int)&DefDummyInterrupt;
> T0TCR = 0;
> T0PC = 0;
> T0CCR = 0;
> T0EMR = 0;
> T0MR0 = 0xFFFF;
> T0MCR = 3;
> VICVectAddr0 = (unsigned int)TIMER0;
> VICVectCntl0 = 0x20 | 4;
> VICIntEnable = 0x00000010;
> T0TCR = 1;
> }
>
> void main(void)
> {
> MA_Reset_SCB();
> MA_Reset_PCB();
> MA_Init_UART0();
> MA_Reset_UART0();
> init_timer();
> for(;;)
> {
> MA_PutChar_UART0(0xD);
> MA_PutChar_UART0(0xA);
> MA_PutChar_UART0(0xD);
> MA_PutChar_UART0(0xA);
> MA_PutString_UART0("SET");
> MA_PutChar_UART0(0xD);
> MA_PutChar_UART0(0xA);
> for(S8 i=0;i<10;i++)
> Sleep(135000);
> }
>
> }
>
> Kindly clarify my doubt.
>
> with regards,
> Raj >

__________________________________________________