PDA

View Full Version : 18F8722 PortF Problem



shawn
- 26th May 2011, 03:45
Hello
I am using a PIC 18F8722 and I am having a problem reading PORTF. I ran into a problem reading the portf in a project of mine and this code I am just testing it to see what happens.

In the code below I set portF to a certain value and then make Temp1 = to PortF to display on a LCD. When the program runs I get all 8 outputs of the pic to turn on but I get a value of 128 to display on the lcd. If I change PortF to any value below 128 I get 0 to display on the LCD. No matter what value I put in I always get the right state on the 8 output pins. I have no Idea what is going on.
DEFINE OSC 40 'Define clock freq. 40MHz
pause 1000
TRISF = 0 'Define PortF TRIS Register.
TRISC.0 = 0 'Define PortC TRIS Register.
LCD Var portC.0 ' LCD Data debuging pin.
Temp1 Var word
PortF = 255
Temp1 = PORTF
Serout2 LCD,16468,[12,DEC Temp1 ]
pause 3000
end


Thanks
Shawn

mackrackit
- 26th May 2011, 05:10
Port F on that chip has some analog features. You will need to turn that off.

shawn
- 27th May 2011, 02:30
Thanks Dave
Turning the AD Module off does not fix the problem but you got me thinking. After I turned the AD module off, I changed ADCON1 0-3 to all digital and that did the trick. Thanks again for the help. I would have beat my head for awhile without your post.

Shawn