/*-------------------*/
#include
#include "hardware.h"
long timeval=0;
__irq __arm void tc0 (void); // Generate Interrupt
void init_timer (void);
/*-------------------*/
void main(void)
{
CPUinit();
init_timer();
A_LED1_ON;
while(1);
}
/* Setup the Timer Counter 0 Interrupt */
void init_timer (void)
{
T0MR0 = 149999; // 10mSec = 150.000-1 counts
T0MCR = 0x03; // Interrupt and Reset on MR0
T0TCR = 0x01; // Timer0 Enable
VICIntSelect = 0x00;
VICVectAddr0 = (U32)tc0; // set interrupt vector in 0
VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
VICIntEnable = 0x00000010; // Enable Timer0 Interrupt
}
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
__irq __arm void tc0 (void)
{
A_LED1_OFF;
VICVectAddr = 0x00; // Acknowledge Interrupt
T0IR = 0x01; // Clear interrupt flag
}
i try to debug this program with IAR and olimex-P2129 and
the program don't launch any interrupt .
why the interrupt is not execute ?! any idea please
this the code of CPUinit();
void CPUinit(void)
{
PLLCFG_bit.MSEL=3; //M=3(4?),P=1(2?) PLLfreq = 235,9296 Mhz,
CCLK = 58,9824 Mhz
PLLCFG_bit.PSEL=1;
PLLFEED=0xAA;
PLLFEED=0x55;
PLLCON_bit.PLLE=1; // Enable the PLL
PLLFEED=0xAA;
PLLFEED=0x55;
while(!(PLLSTAT & PLOCK)); // Wait for PLL to lock
//Init MAM & Flash memory fetch
MAMCR_bit.MODECTRL=2;
MAMTIM_bit.CYCLES=4;
VPBDIV_bit.VPBDIV=1; //pclk = cclk
//GPIO init
A_PULL_UP;
A_LED1_OFF;
A_LED2_OFF;
PINSEL0=0; //P0 lower 16 bits all GPIO
PINSEL1=0; //P0 upper 16 bits all GPIO
IO0DIR=0x01003101;
//IODIR in binary 0000 0001 0000 0000 0011 0001 0000 0001 //...P0.12, P0.13
are output(LEDs) also TXD0,TXD1,TD2
VICProtection = 0;
}
IAR LPC2129 TIMER INTERRUPT PROGRAM not work
Started by ●November 24, 2010