LPC 2148 Timer Programs only
LPC 2148 Timer Programs only
AIM:
CALCULATION:
Pclk = CCLK/4 = 60 MHz / 4 = 15 MHz
Clock Frequency = 15 MHz / (2+1) = 5 MHz
PROGRAM:
#include"LPC214X.h"
int main()
{
PINSEL0=0x00000080; //Enable pin corresponding to timer0
T0PR=0x000003e7; //32-bit Pre-scalar register (PR) can be used to divide the
// Processor clk by PR+1 before applied to counter
T0MCR=0x00000003; // Used to reset the count register (TMR) after every match
// for subsequent cycles
T0EMR=0x00000030; // select the type of change in the respective match output
// pin that indicates the occurrence of match
T0MR0=0x00003a98; // Select one of the four MRn and Load it with maximum count.
// TxMRn = Processor clk / Required output frequency.
// where, x = 0 or 1 and n=0 to 3.
T0TCR=0x01;
return(0);
}
SAMPLE OUTPUT:
1
APPLICATION PROGRAM WITH INTERRUPTS
AIM:
To write an embedded C program to toggle a GPIO pin for every 1 s using IRQ of VIC
modulein LPC 2148 controller.
ALGORITHM:
CALCULATION:
2
PROGRAM:
#include <LPC214x.h>
void timer(void)__irq
IO1PIN=0X00002A80;
VICVectAddr=0;
int main()
inti;
while(1)
3
i++;
return(0);
SAMPLE OUTPUT:
4
RESULT:
The embedded C program to toggle a GPIO pin for every 1 s using IRQ of VIC module
in LPC 2148 controller has been written, executed and verified.