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.

[SOLVED] Clock edit function not working

Status
Not open for further replies.

MKVRAJU

Junior Member level 2
Joined
Jun 14, 2013
Messages
20
Helped
1
Reputation
2
Reaction score
1
Trophy points
3
Activity points
160
hiii i am using PIC30F5011.

I have Written Clock edit function but its not working
i have three switches on RG12,RG0,RG1 pins
TRISGbits.TRISG12=1;
TRISGbits.TRISG0=1;
TRISGbits.TRISG1=1;


when i was press RG14 controller goes to clokedit function but its not going to switch function ..what did i wrong.can any one help or any other suggestion for writing Clockedit function

while(1)
{
if(PORTGbits.RG14)
{
Clockedit(); //Calling Clockedit function
}
}

void Clockedit(void)
{
unsigned int count=1;

while(count<=4)
{

switch(count)
{

case 1: MoveRight(14); // cursor position
if(PORTGbits.RG0 && ClockTime.Hours<24)
ClockTime.Hours++;
if(PORTGbits.RG1 && ClockTime.Hours>=0)
ClockTime.Hours--;
break;

case 2: MoveRight(17); // cursor position
if(PORTGbits.RG0==1 && ClockTime.Minutes<60)
ClockTime.Minutes++;
if(PORTGbits.RG1==1 && ClockTime.Minutes>=1)
ClockTime.Minutes--;
break;

case 3: MoveRight(20); // cursor position
if(PORTGbits.RG0==1 && ClockTime.Seconds<60)
ClockTime.Seconds++;
if(PORTGbits.RG1==1 && ClockTime.Seconds>=1)
ClockTime.Seconds--;
break;

case 4: Clock(); // calling for update clock

}
if(PORTGbits.RG14==1)
count++;
}
}
 

Maybe count value is exceeding value 4 and then switch is not executing. Put a debounce delay for if(PORTGbits.RG14) if it is a switch. Also replace

if(PORTGbits.RG0 && ClockTime.Hours<24)

with

if((PORTGbits.RG0) && (ClockTime.Hours<24))
 

hiiiii

thank you very much jayanth.devarayanadurga
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top