Microchip forum

Thread Starter

PRS

Joined Aug 24, 2008
989
Does anyone here have experience with the Microchip forum? I signed up and posted one post and that is all it let me post. Also, it won't let me reply to the fellow who replied to my post. What's up with this?
 

hgmjr

Joined Jan 28, 2005
9,027
I suggest you contact the administrator of the forum. You should be able to post freely once you have joined the site.

hgmjr
 

Thread Starter

PRS

Joined Aug 24, 2008
989
Thanks for the tip. I guess I'll get hold of the supervisor as suggested. But maybe you could answer my question:

I'm using a PIC18f452 with PicKit3, and I'm using C18. The latter is the kicker. I can read the documentation for PORTA such that I could configure it for digital IO on PORTA using ASM, but I see no documentation for C. Do you know the answer?
 

spinnaker

Joined Oct 29, 2009
7,830
Thanks for the tip. I guess I'll get hold of the supervisor as suggested. But maybe you could answer my question:

I'm using a PIC18f452 with PicKit3, and I'm using C18. The latter is the kicker. I can read the documentation for PORTA such that I could configure it for digital IO on PORTA using ASM, but I see no documentation for C. Do you know the answer?

Look for the document called PICkit™ 3 Debug Express PIC18F45K20 – MPLAB® C Lessons on the Microchip website.

Go through the lessons. If you have a question, post back.
 

Thread Starter

PRS

Joined Aug 24, 2008
989
Look for the document called PICkit™ 3 Debug Express PIC18F45K20 – MPLAB® C Lessons on the Microchip website.

Go through the lessons. If you have a question, post back.
I wish that were true, spinnaker, but I am using a PIC18f452 and they are different.
 

Thread Starter

PRS

Joined Aug 24, 2008
989
So what happens, blueroom? I configured my PortA for output and it worked just fine, then I configured it for input and it was zero, not what I told it to be.. What is happening? I just presumed it was a configuration problem. Am I wrong? My thought is that PortA is analog to digital and I have to figure out how to turn it into digital IO using C18.
 

spinnaker

Joined Oct 29, 2009
7,830
So what happens, blueroom? I configured my PortA for output and it worked just fine, then I configured it for input and it was zero, not what I told it to be.. What is happening? I just presumed it was a configuration problem. Am I wrong? My thought is that PortA is analog to digital and I have to figure out how to turn it into digital IO using C18.



You read ports you write to latches. Also check to see if the port is an analog port. Look at ANSEL in your datasheet.

Do you have a pull up resistor?

Look at the samples as I recommended.
 
Last edited:

cheezewizz

Joined Apr 16, 2009
82
The datasheet says ...
Rich (BB code):
Note: On a Power-on Reset, RA5 and RA3:RA0
are configured as analog inputs and read
as ‘0’. RA6 and RA4 are configured as
digital inputs.
The operation of each pin is selected by clearing/setting the
control bits in the ADCON1 register (A/D Control
Register1).
so it should be simply a case of setting
Rich (BB code):
ADCON1 = 0x07;
 

thatoneguy

Joined Feb 19, 2009
6,359
on 18 devices, you write to LATx, but read PORTx

In most cases PORTA, you can think "PORTAnalog", and remember to disable the analog hardware for digital I/O on PORTA/LATA.

Once disabling comparators, etc, I've not had a problem working with PortA.

Can you paste the source code you are using?
 
Top