Dear Friends,
I am experiencing a very frustating situation and I am hoping someone can help me solve this problem.
I have been using Pics for almost 10 years, now, but this problem baffles me. I am using a pic18F8722, and I cannot set porta.o using the following statement: porta.0=1 or porta.0=0. In either cases, it remains high. The tris setting configures it as an output (trisa=0), and all other bits on the port work fine (excluding a.4 of course, which is open-collector).
However, I can set the pin by using HIGH porta.0 or LOW porta.0.
I have been trying to figure out the reason behind this for 3 days now, but I give up. I have found a work around by using select case in the following way:
dummy= state of the pin I want to set
select case dummy
case 0
low porta.0
case 1
high porta.0
end select
It works, but it is not very elegant...
even this small program does not work:
trisa=0
main:
porta.0=0
porta.1=0
pause 10
porta.0=1
porta.1=1
pause 10
goto main
when I check the pins with my scope, I see a nice square wave on porta.1, but port a.0 stays high.
If I change the program to:
trisa=0
main:
low porta.0
porta.1=0
pause 10
high porta.0
porta.1=1
pause 10
goto main
Then I see a square wave on both pins.
My question is: what is the difference between the code generated with
porta.0=1
and
high porta.0
why is one expression working and not the other one?
(by the way, yes, the fuses are properly set, ADCON1=%00000111 to set the outputs as digital, A/D module disabled, etc...)
I appreciate your help.
Best regards,
Patrice
Bookmarks