Pumpkin, Inc.

Pumpkin User Forums

PIC and PORT in input Mode

If you can't make Salvo do what you want it to do, post it here.

PIC and PORT in input Mode

Postby stephane » Mon Apr 26, 2004 5:26 am

Hello,

LCDRetro is a function to switch on/off a backlight.

When I push the button, RA4=0 and the backlight switch "on". But, I want that when I push the button again, the backlight switch "off" but it is not what happen : the
backlight stay "on" or, switch "on off" rapidly. It is like that Salvo execute the
first part and the second after at the same time.
I don't know how I can do ?

My code is like this :

code:
void TaskRetro(void)
{
for( ; ; )
{
if(test)
{
if(!RA4)
{
if(nbr_fois==0x00)
{
LCDRetro(ON);
TMR1ON=1;
nbr_fois=0x01;
test=0x00;
break;
}
if(nbr_fois==0x01)
{
test=0x00;
LCDRetro(OFF);
TMR1ON=0;
TMR1L=0x00;
TMR1L=0xe5;
TMR1H=0xf9;
nbr_fois=0x00;

}
}
}
OS_Yield(TaskRetro2);
}
}

Regards.

Stephane

NB : Excuse me for my English.... ;-)

[This message has been edited by aek (edited April 26, 2004).]

stephane
 
Posts: 2
Joined: Sun Apr 25, 2004 11:00 pm
Location: france

Re: PIC and PORT in input Mode

Postby aek » Mon Apr 26, 2004 6:15 am

Hi Stephane.

From the Power C Compiler Manual:

"The break statement can be used in a while, do-while or for statement."

Your code is doing what it should ... I suggest you use an if() ... else if() construct instead.

BTW, there's an elegant key-debounce task in this Pumpkin AppNote: http://www.pumpkininc.com/content/doc/appnote/an-6.pdf ... see TaskReadKeys().

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: PIC and PORT in input Mode

Postby stephane » Tue Apr 27, 2004 2:05 am

Hello,
Thank you for your help .
Regard.
Stephane
stephane
 
Posts: 2
Joined: Sun Apr 25, 2004 11:00 pm
Location: france


Return to Coding

Who is online

Users browsing this forum: No registered users and 3 guests

cron