TIMER PROGRAMS FOR LPC2129

                 TIMER PROGRAMS FOR LPC2129


program for creating interpret using match registers?


#include<lpc21xx.h>
void delay(int count)
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<1000;j++)
{
}
}
}
int main()           
{
 IODIR1|=(0xff<<17);
T0TCR=1<<0;
T0PR=14;
T0MR0=5000000;
T0MR1=10000000;
T0MR2=15000000;
T0MR3=20000000;
T0MCR=(1<<0)|(1<<3)|(1<<6)|(1<<9)|(1<<10);// only interpet ,reset and set
while(1)
{
if(T0IR&(1<<0))
{
IOSET1=(1<<17);
delay(500);
IOCLR1=(1<<17);
delay(500);
}
T0IR=(1<<0);

if(T0IR&(1<<1))
{
IOSET1=(3<<17);
delay(500);      
IOCLR1=(3<<17);
delay(500);
}
T0IR=(1<<1);

if(T0IR&(1<<2))
{
IOSET1=(7<<17);
delay(500);
IOCLR1=(7<<17);
delay(500);
}
T0IR=(1<<2);

if(T0IR&(1<<3))
{
IOSET1=(0x0f<<17);
delay(500);
IOCLR1=(0x0f<<17);
delay(500);
}
T0IR=(1<<3);
}

}


Blinking led without using delay function?


#include<lpc21xx.h>

int main()           
{
IODIR1|=(0xff<<17);
T0TCR=1<<0;
T0PR=14;
T0MR0=500000;
T0MR1=5000000;
T0MCR=(1<<0)|(1<<3)|(1<<4);// only interpet ,reset and set
while(1)
{

if(T0IR&(1<<0))
{
IOSET1=(7<<17);
T0IR=(1<<0);
}
if(T0IR&(1<<1))
{
IOCLR1=(7<<17);
T0IR=(1<<1);
}
}
}



Blinking led with using delay function?

#include<lpc21xx.h>
void delay(int count)
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<1000;j++)
{
}
}
}
int main()
{
int i;
IODIR1|=h(0xff<<17);
T0TCR=1<<0;
T0PR=14;
T0MR0=5000000;
T0MCR=(1<<0)|(1<<1);
while(1)
{
if(T0IR&(1<<0))
{
for(i=17;i<25;i++)
{
IOSET1=(1<<i+1);
delay(500);
IOCLR1=(1<<i);
delay(500);
}
T0IR=(1<<0);
}
}
}


Hardware delay using the timer? 



#include<lpc21xx.H>
#define PRESCALE 15000
void delay(int mill)
{
T0TCR=(1<<1);     
T0TCR=(1<<0);
while(T0TC<mill)
{
T0TCR=0x00;
}
}
int main()
{
IODIR1|=(1<<17);
T0TCR=(1<<0);
T0PR=PRESCALE-1;
T0MR0=5000000;
T0MCR|=(1<<0)|(1<<1);
while(1)
{
IOSET1=(1<<17);
delay(1000);
IOCLR1=(1<<17);
delay(1000);
}
 }



Comments

Popular posts from this blog

READING VALUES FROM SENSOR AND THAT WRITING TO EEPROM

Smart Power management system in any management system

project for checking status of lights very day 12 :11 am