Pullups/pulldowns on discrete inputs

An area to discuss 16-bit PIC specific problems and examples

Moderator: Benj

Post Reply
csouter
Posts: 21
Joined: Fri Jul 28, 2017 10:58 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Pullups/pulldowns on discrete inputs

Post by csouter »

How can I disable the pull-ups and pull-downs on a discrete input - i.e., I want to put the output logic into a tristate mode. Specifically, on pin B10 of a PIC24FJ256GB106. I am connected to a circuit that is extremely sensitive (and I can't get the board reworked at this stage of the game), and any pull-up or pull-down on the input pin causes me to not be able to read the discrete reliably. I can get the circuit to and the input pin to work if I program it in MpLab, but I can't get the equivalent logic to work in FlowCode.

Thank you.
Clive Souter

csouter
Posts: 21
Joined: Fri Jul 28, 2017 10:58 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Pullups/pulldowns on discrete inputs

Post by csouter »

I finally figured out how to enable a pull-down on I/O Pin B10 (CNPD28), but I am still not able to read the input. I have a hard 3.3V input on the pin, and I always read a zero. Anybody have any suggestions?

Thank you
csouter

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Pullups/pulldowns on discrete inputs

Post by Benj »

Hi Csouter,

An interesting snippet from the datasheet in section 10.2.
The AD1PCFGL and TRIS registers control the operation of the A/D port pins. Setting a port pin as an analog input also requires that the corresponding TRIS bit be set. If the TRIS bit is cleared (output), the digital output level (VOH or VOL) will be converted. When reading the PORT register, all pins configured as analog input channels will read as cleared (a low level).
The start of the Main function in the C code should have this line of code to set all the analogue pins to digital mode. Can you check this line is present in your C file.

Code: Select all

AD1PCFG = 0xffff;
Simply reading a pin connected to VCC using an input icon or an assignment in the calculation icon should return a 1. Can you confirm the voltage is present on the pin using a multimeter to confirm there are no breaks in the circuit.

Post Reply