View previous topic :: View next topic |
Author |
Message |
[email protected]
Joined: 24 Mar 2010 Posts: 24
|
pic18f86j90 RB4 and RB5 pullups are read as 0 |
Posted: Tue Oct 02, 2018 3:31 am |
|
|
Hi,
I am using pic18f86j90 with CCS ver 4.099.
My firmware has some basic inits (like ports, A/D and some more modules) and then comes the following code:
if ((input(HW_KEY_OK) == 0)&&(input(HW_KEY_AUTO) == 0))
{
DigitDisplay(CHR_R, CHR_S, CHR_T);
ResetEEprom();
DigitDisplay(CHR_E, CHR_N, CHR__d);
}
HW_KEY_OK is RB4 and HW_KEY_AUTO is RB5 with pullups enabled.
The problem: while both switchs(HW_KEY_OK and HW_KEY_AUTO) are not pressed sometimes the code inside the "if" is executed and sometimes not. This is driving me crazy.
I looked at the RB4,RB5 signals using oscilloscope and they are always high (pulled-up) even when problem occurs.
Does someone have a clue what's going on here?
Regards,
Gil _________________ Gil F. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Tue Oct 02, 2018 4:12 am |
|
|
They are probably not reliably high.
The internal pull-ups are very low current sources. Just 30uA typically. It doesn't take much EMI, for a line pulled up with this small current, to be momentarily taken low enough to not be seen as 'high'.
Are you absolutely sure you are enabling the pull-ups?. You realise 'TRUE' would not enable them?. They are per bit settable on this chip. |
|
|
[email protected]
Joined: 24 Mar 2010 Posts: 24
|
|
Posted: Tue Oct 02, 2018 6:16 am |
|
|
Sorry for misleading. The error is not in the code displayed above.
Case closed _________________ Gil F. |
|
|
|