eray81
Junior Member level 3
Hi,
I want to toggle a pin with timer0. I wrote the code below but it doesnt work.
help please ;-)
I want to toggle a pin with timer0. I wrote the code below but it doesnt work.
help please ;-)
Code:
#include <LPC21xx.H>
void T0isr(void) __irq;
volatile int i=0;
volatile int num=0;
int main(void)
{
IODIR0 = 0XFFFFFFFF;
T0IR = 1;
T0CCR = 0;
T0PR = 12000;
T0MR0 = 4;
T0MCR = 3;
T0TCR = 1;
VICVectAddr4 = (unsigned)T0isr; //Set the timer ISR vector address
VICVectCntl4 = 0x00000024; //Set channel
VICIntEnable |= 0x00000010; //Enable the interrupt
}
void T0isr(void) __irq
{
T0IR = 1;
if(++i==100){
IO0SET = 0x00000001;
i=0;
}
}
Last edited by a moderator: