fyp
Newbie level 1
hi can anyone help me!!!.... Iam doing this project regarding pic18f452. I have to build a program that have a delay of a second, mins and hour respectively. i have done the delay of this three timing but dun knw how to make it wrk at the same time, as u can see nw it can only loop one at a time followed by d next delay by using the break;
So can anybody help me...... nd each individual delays to keep looping as well as all the three delay start at same time.
#include <p18F452.h> /* Inserting full text from p18F452.h */
#include <delays.h> /* This file contains processor specific C */
/* code */
unsigned int i;
main(void)
{
TRISCbits.TRISC0=0; // Set RC2 as output
TRISBbits.TRISC1=0;
TRISBbits.TRISC4=0;
TRISBbits.TRISC5=0;
TRISBbits.TRISB4=0;
TRISBbits.TRISB5=0;
TRISC = 0x00; /* Set all pins on PortC as outputs */
TRISB = 0x00;
//Delay for second
while(1)
{
PORTB=0b00110000;
for (i = 0; i <4 ; i++)
{
Delay1KTCYx(250);
}
PORTB=0b00000000;
for (i = 0; i <4 ; i++)
{
Delay1KTCYx(250);
}
break;
}
//Delay for minutes
while(1)
{
PORTC=0b00000001;
for (i = 0; i < 240; i++)
{
Delay1KTCYx(250);
}
PORTC=0b00000010;
for (i = 0; i < 240; i++)
{
Delay1KTCYx(250);
}
break;
}
//Delay for hour
while(1)
{
PORTC=0b00010000;
for (i = 0; i <1440 ; i++)
{
Delay1KTCYx(250);
}
PORTC=0b00100000;
for (i = 0; i <1440 ; i++)
{
Delay1KTCYx(250);
}
break;
}
}// close for main(void)
So can anybody help me...... nd each individual delays to keep looping as well as all the three delay start at same time.
#include <p18F452.h> /* Inserting full text from p18F452.h */
#include <delays.h> /* This file contains processor specific C */
/* code */
unsigned int i;
main(void)
{
TRISCbits.TRISC0=0; // Set RC2 as output
TRISBbits.TRISC1=0;
TRISBbits.TRISC4=0;
TRISBbits.TRISC5=0;
TRISBbits.TRISB4=0;
TRISBbits.TRISB5=0;
TRISC = 0x00; /* Set all pins on PortC as outputs */
TRISB = 0x00;
//Delay for second
while(1)
{
PORTB=0b00110000;
for (i = 0; i <4 ; i++)
{
Delay1KTCYx(250);
}
PORTB=0b00000000;
for (i = 0; i <4 ; i++)
{
Delay1KTCYx(250);
}
break;
}
//Delay for minutes
while(1)
{
PORTC=0b00000001;
for (i = 0; i < 240; i++)
{
Delay1KTCYx(250);
}
PORTC=0b00000010;
for (i = 0; i < 240; i++)
{
Delay1KTCYx(250);
}
break;
}
//Delay for hour
while(1)
{
PORTC=0b00010000;
for (i = 0; i <1440 ; i++)
{
Delay1KTCYx(250);
}
PORTC=0b00100000;
for (i = 0; i <1440 ; i++)
{
Delay1KTCYx(250);
}
break;
}
}// close for main(void)