/*-- Company: AtomSoft ..... Author: Jason Lopez --*/
/*-- Please download --- UM10139: Volume 1: LPC214x User Manual --*/
/*-- As i will refer to it for more info here... --*/
#include <LPC214x.h>
#include <ctl_api.h>
void Initialize(void);
int main(void);
void Init_ISR(void);
void delay_isr(void);
volatile int en;
volatile int Timer_Flag;
void Initialize(void) { //12 Mhz
PLL0CON=0x0;
PLL0FEED=0xAA;
PLL0FEED=0x55;
VPBDIV=0x01;
}
void Init_ISR(void) {
T0TCR = 0x02;
T0IR = 0xFF;
T0MCR = 0x0003;
T0MR0 = 6000000; //temp it doesnt matter....
VICVectCntl0 = 0x00000024;
VICVectAddr0 = (unsigned)delay_isr;
VICIntEnable = 0x00000010;
en = libarm_set_irq(1);
}
void delay(int length, int type) {
switch(type){
case 0:
type = 12;
break;
case 1:
type = 12000;
break;
case 2:
type = 12000000;
break;
default:
type = 0;
break;
}
Timer_Flag = 1;
T0TCR = 0x02;
T0IR = 0xFF;
T0MCR = 0x0003;
T0MR0 = length * type;
T0TCR = 0x01;
while(Timer_Flag);
}
void delay_isr(void){
T0IR = 1;
Timer_Flag = 0;
libarm_set_irq(en);
}