___________________________________________________________________________________________________
____________________________________________________________________________________________________ ____________________________________________________________________________________________________ Content for the tab VIDEO
1. CREATING A DELAY OF 1 SEC USING TIMERS OF ARM7 ( LPC2148 )
/******************************************************
www.firmcodes.com
DEVELOPED BY:- FIRMWARE DEVELOPER
WHAT PROGRAM DO:- CREATING DELAY OF 1 SEC USING TIMER 0 OF ARM7(LPC2148)
******************************************************/
#include<lpc21xx.h>
# define PRESCALAR 60000 // define prescalar as 60000
void pll();
void timer0_ini();
void delay(unsigned long int ms);
int main()
{
PINSEL0=0x00000000; // select gpio pin
IO0DIR=0XFFFFFFFF; // make gpio as output pin
pll(); // calling pll function
timer0_ini(); // calling timer function
while(1)
{
IO0SET=0XFFFFFFFF; // led on
delay(0x000000fF); // delay using timer 0
IO0CLR=0XFFFFFFFF; // led off
delay(0x000000fF); // delay using timer 0
}
return 0;
}
void pll()
{
//PLL IS CONFIGURED TO GET 60HZ pCLK
PLLCFG=0X24; // SET PSEL=2 AND MSEL=5
PLLCON=0X01; //PLL IS ACTIVE BUT NOT YET CONNECT
PLLFEED=0XAA; //FEED SEQUENCE
PLLFEED=0X55; //FEED SEQUENCE
while((PLLSTAT & 0X400)==0); //WAIT FOR FEED SEQUENCE TO BE INSERTED
PLLCON=0X03; // PLL HAS BEEN ACTIVE AND BEING CONNECTRD
VPBDIV=0X00; // SET PCLK SAME AS FCCLK
PLLFEED=0XAA; //FEED SEQUENCE
PLLFEED=0X55; //FEED SEQUENCE
}
void timer0_ini()
{
T0TCR=0X0; // to stop timer
T0PR=PRESCALAR-1; //load the timer value
T0TCR=0X02; //reset timer
}
void delay(unsigned long int ms)
{
T0TC=0x00000000; // t0 reset timer counting
T0TCR=0X02; // reset the timer
T0TCR=0X01; // start timer
while(T0TC<=ms); // check the condition
T0TCR=0X00; // stop timer
}
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
2. CREATING A SQUARE WAVE OF 100 MS USING TIMERS OF ARM7 ( LPC2148 )
/******************************************************
www.firmcodes.com
DEVELOPED BY:- FIRMWARE DEVELOPER
WHAT PROGRAM DO:- CREATING A SQUARE WAVE OF 100 MS USING TIMER 0 OF ARM7(LPC2148)
******************************************************/
#include<lpc21xx.h>
# define PRESCALAR 60000 // define prescalar as 60000
void pll();
void timer0_ini();
void delay(unsigned long int ms);
int main()
{
PINSEL0=0x00000000; // select gpio pin
IO0DIR=0XFFFFFFFF; // make gpio as output pin
pll(); // calling pll function
timer0_ini(); // calling timer function
while(1)
{
IO0SET=0X01; // high level
delay(0x0000000F); // delay using timer 0
IO0CLR=0X01; // low level
delay(0x0000000F); // delay using timer 0
}
return 0;
}
void pll()
{
//PLL IS CONFIGURED TO GET 60HZ pCLK
PLLCFG=0X24; // SET PSEL=2 AND MSEL=5
PLLCON=0X01; //PLL IS ACTIVE BUT NOT YET CONNECT
PLLFEED=0XAA; //FEED SEQUENCE
PLLFEED=0X55; //FEED SEQUENCE
while((PLLSTAT & 0X400)==0); //WAIT FOR FEED SEQUENCE TO BE INSERTED
PLLCON=0X03; // PLL HAS BEEN ACTIVE AND BEING CONNECTRD
VPBDIV=0X00; // SET PCLK SAME AS FCCLK
PLLFEED=0XAA; //FEED SEQUENCE
PLLFEED=0X55; //FEED SEQUENCE
}
void timer0_ini()
{
T0TCR=0X0; // to stop timer
T0PR=PRESCALAR-1; //load the timer value
T0TCR=0X02; //reset timer
}
void delay(unsigned long int ms)
{
T0TC=0x00000000; // t0 reset timer counting
T0TCR=0X02; // reset the timer
T0TCR=0X01; // start timer
while(T0TC<=ms); // check the condition
T0TCR=0X00; // stop timer
}
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)