Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help souce code pic18f452

Status
Not open for further replies.

fyp

Newbie level 1
Newbie level 1
Joined
Dec 20, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,296
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)
 

You just need one delay loop of one second. Call it, when it returns, increment your counter.
Then you have a counter, when you have 60 seconds, you have a minute, 60 minutes an hour etc.
 

hi....i am also using same things for my project.....do you hav solution already?? thanks alot....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top