Well actually, If you were to put a scope on the led pin you should see it toggling with a period of 50 Milliseconds while the push button is being pressed. I assume you have a pullup resistor connected to +5 volts and the Porta.3 pin?
Well actually, If you were to put a scope on the led pin you should see it toggling with a period of 50 Milliseconds while the push button is being pressed. I assume you have a pullup resistor connected to +5 volts and the Porta.3 pin?
Dave Purola,
N8NTA
EN82fn
I see your point. But the flaw in the code is not the underlying problem. It should flicker while the button is held down. And then land on ON or OFF 50:50, right? I changed the pause to 1000 and it's still the same. Yes, I have the a 10k pull up resistor to Vdd. Does the config section look correct? For some reason, the TRIS reg didn't cut and past completely. It should be
TRISA = %11001000
Does that look correct?
Do I need to do something with the C registry?
I don't see where you are configuring the analog select register ANSEL.
By not explicitly setting the value of this register the PIC is using the default value, which might be enabling some pins as analog.
Check the Datasheet to verify how you want them set and make sure you add the appropriate ANSEL = xxx statement to the beginning of your program.
That may be causing you a problem.
I have found it is usually a good idea to check and set the registers for all of the hardware modules.
Might be worth checking.
Regards,
TABSoft
Bookmarks