Smartie
Member
Hey Guys,
I've got Crossworks for Arm installed and talking to a LPC2138 using a Bus Blaster. I've gotten a blinky light working on the new board so the chip is working and I can see all the registers when debugging.
I've tried to set up a timer interrupt to get an understanding about how the vectored interrupts work but sadly I can't get the timer to trigger an event
when i poked around in the registers, the Timer0Counter (T0TC) does not change over time, the same with with the pre-scale counter (T0PC) but since the pre-scale register (T0PR) isn't set, T0PC shouldn't be changing anyway.
Here is my timer.cpp:
the usage of the above code is called in main.cpp like this:
Is anyone able to shed some light onto my situation?
I've got Crossworks for Arm installed and talking to a LPC2138 using a Bus Blaster. I've gotten a blinky light working on the new board so the chip is working and I can see all the registers when debugging.
I've tried to set up a timer interrupt to get an understanding about how the vectored interrupts work but sadly I can't get the timer to trigger an event
when i poked around in the registers, the Timer0Counter (T0TC) does not change over time, the same with with the pre-scale counter (T0PC) but since the pre-scale register (T0PR) isn't set, T0PC shouldn't be changing anyway.
Here is my timer.cpp:
Code:
int tmr1cnter = 0;
void uDelay(int x){
tmr1cnter = x;
while(tmr1cnter);
}
void __attribute__ ((interrupt)) t0isr(void){
T0IR |= T0IR_MR0;
if(tmr1cnter>0){
tmr1cnter--;
}
VICVectAddr = 0;
}
void init_timer0(void){
//--- Timer 0 - interrupt 10 ms
//T0PR = 50; //-- Prescaler = 0
//T0PC = 0; // Prescaler Counter
//T0MR0 = 60000 * 10; //clock rate of 60000 * 10ms ?
T0IR = 0x01;
T0CTCR &= 0xFC;
T0MR0 = 599 ; // 1ms
T0MCR = T0MCR_MR0I | T0MCR_MR0R; //-- bit 0=1 -int on MR0 , bit 1=1 - Reset on MR0
T0TC = 0x00;
T0PR = 0x00;
T0PC = 0x00;
T0TCR |= T0TCR_Counter_Enable; //-- Timer 0 - run
//VICIntSelect &= ~BIT(4); // ~BIT(VIC_TIMER0);
VICVectAddr0 = (unsigned)t0isr;//-- Timer 0 int - prioritytop-1
VICVectCntl0 = 0x24; // VIC_ENABLE | VIC_TIMER0;
VICIntEnable |= 0x0010; // BIT(VIC_TIMER0);
}
the usage of the above code is called in main.cpp like this:
Code:
#include "timer.h"
#include <targets/LCP21xx.h>
#include <ctl_api.h>
// ...
int main(){
ctl_global_interrupts_enable();
init_timer0();
// ...
while (1)
{
uDelay(100);
IO0CLR = 0x80000000; // Turn the LED off
uDelay(100);
IO0SET = 0x80000000; // Turn the LED on
}
}
Is anyone able to shed some light onto my situation?
Last edited: