TIMER using LPC2148:
Ex-
#include<lpc214x.h>
#define PLLE 0
#define PLLC 1
#define PLOCK 10
void pllinit();
void delay(int);
int main()
{ IO0DIR=IO0DIR|(1<<0);
pllinit();
while(1)
{
IO0SET=IO0SET|(1<<0);
delay(1);
IO0CLR=IO0CLR|(1<<0);
delay(1);
}
return 0;
}
void delay(int ms)
{
T0CTCR=0x00; //select timer mode
T0TC=0;//how many times this prog operate
T0PC=0; //start 00
T0PR=59999;// move upto 59999
T0TCR=0x02;
T0TCR=0x01;
while( T0TC != ms);
T0TCR=0;
}
void pllinit()
{
PLL0CFG=0x24;
PLL0CON=PLL0CON|(1<<PLLE);
PLL0FEED=0xAA;
PLL0FEED=0x55;
//PLL0CON=PLL0CON|(1<<PLLC);
while( (PLL0STAT & (1<<PLOCK))==0);
PLL0CON=PLL0CON|3;
PLL0FEED=0xAA;
PLL0FEED=0x55;
VPBDIV=0x01;
}
Ex-
#include<lpc214x.h>
#define PLLE 0
#define PLLC 1
#define PLOCK 10
void pllinit();
void delay(int);
int main()
{ IO0DIR=IO0DIR|(1<<0);
pllinit();
while(1)
{
IO0SET=IO0SET|(1<<0);
delay(1);
IO0CLR=IO0CLR|(1<<0);
delay(1);
}
return 0;
}
void delay(int ms)
{
T0CTCR=0x00; //select timer mode
T0TC=0;//how many times this prog operate
T0PC=0; //start 00
T0PR=59999;// move upto 59999
T0TCR=0x02;
T0TCR=0x01;
while( T0TC != ms);
T0TCR=0;
}
void pllinit()
{
PLL0CFG=0x24;
PLL0CON=PLL0CON|(1<<PLLE);
PLL0FEED=0xAA;
PLL0FEED=0x55;
//PLL0CON=PLL0CON|(1<<PLLC);
while( (PLL0STAT & (1<<PLOCK))==0);
PLL0CON=PLL0CON|3;
PLL0FEED=0xAA;
PLL0FEED=0x55;
VPBDIV=0x01;
}
0 comments:
Post a Comment
if you have any doubt please let me know