Some GPIO pins not working - PIC damaged?

Find out how to setup your programmer's software and how to solve many common problems.

Moderator: phalanx

Post Reply
wave.jaco
Posts: 28
Joined: Sat Aug 01, 2015 2:45 am
Location: South Africa

Some GPIO pins not working - PIC damaged?

Post by wave.jaco » Tue Oct 11, 2016 10:54 pm

Hi all. I have a PIC32MX664F128H of which some of the GPIO pins are not working as expected. In particular, some of the PORTB pins are relevant. All of the pins involved are configured as follows:

[*] TRISB register all zeroes (all outputs)
[*] AD1PCFG register all ones (digital - the pins in question are multiplexed with some analog channels and PMP pins)
[*] ODCx register all zeroes (I even tried setting the respective applicable bits to 1, with no change noticed)

The PIC is powered at 3.3 V. When switching some of these pins to HIGH, they simply refuse to go to HIGH and just remain at LOW (literally 0 - 0.01 V on the multimeter). Another pin simply stays at a voltage of around 2.08 V, and doesn't turn off/on when commanded to do so in the code. Some of the other GPIO pins work fine as expected. Unfortunately I do not have the code with me at the moment, but the pins are controlled by writing either a 1 or 0 to the PORTxbits.Rxy register (x - port name, y - pin number). Writing to the corresponding LATx register instead also has no effect. These pins are binary inputs to a 74HC238 decoder, so they cannot be pulled low/high by the IC (which works as it should). Therefore my conclusion is that it has to be the PIC at fault.

Has anyone experienced similar behavior with a PIC? Could the PIC possibly be damaged, given this description? I will provide the code when I am at it again; I just hoped I could get some opinions on this situation in the meantime.

Thanks in advance!

User avatar
phalanx
Non-SFE Guru
Posts: 1980
Joined: Sun Nov 30, 2003 8:57 am
Location: Candia, NH

Re: Some GPIO pins not working - PIC damaged?

Post by phalanx » Wed Oct 12, 2016 8:26 am

Which specific pins on PORTB are you having a problem with? Is it by chance RB10, RB11, RB12, and RB13? These pins are shared with the JTAG controller which is enabled by default. You need to disable the JTAG port in your configuration bit settings.

After that, I would need to take a look at your source code to see if anything was overlooked. The pins on PICs and most other comparable microcontrollers are fairly robust so while possible, I'd say it's unlikely that they are damaged.

-Bill

wave.jaco
Posts: 28
Joined: Sat Aug 01, 2015 2:45 am
Location: South Africa

Re: Some GPIO pins not working - PIC damaged?

Post by wave.jaco » Thu Oct 13, 2016 1:00 am

Bingo! Phalanx, you are simply a sharp genius! I have made this mistake before (forgetting to disable the JTAG port) and cannot believe that I have made it again. The pins were indeed those multiplexed with the JTAG port.

What is worthwhile to mention is the fact that the JTAG port for this particular PIC does not get disabled from the configuration bits directly (at least, I haven't found a configuration bit for this in MPLAB X). It has to be disabled by clearing the JTAGEN-bit from the Debug Data Port Control (DDPCON)-register as follows:

Code: Select all

DDPCONbits.JTAGEN = 0;
I guess this is why I missed it on this particular PIC, since I always disable the JTAG port from the configuration bits directly.

Hopefully this might be useful for someone in the future that might also stumble upon this problem.

Thanks for helping me resolve this issue!

User avatar
phalanx
Non-SFE Guru
Posts: 1980
Joined: Sun Nov 30, 2003 8:57 am
Location: Candia, NH

Re: Some GPIO pins not working - PIC damaged?

Post by phalanx » Thu Oct 13, 2016 6:16 am

I've been there before too and I've had to beat it into my head that if I'm using 16 or 32 bit PIC, I have to disable analog and disable JTAG for basic operation. Depending on the part, sometimes running in debug mode will cause MPLAB to set or clear certain bits while a normal program cycle doesn't. You spend hours debugging your code and everything is running smoothly then you program it to run stand-alone and nothing works! Now regardless of the initialized state of any peripheral registers I make use of, I always explicitly set them to what I need.

The JTAG enable bit not being part of the configuration bits is new to me. I'll keep that in the back of my head for the day it becomes a problem for me.

I'm glad it was something simple!

Cheers!

-Bill

wave.jaco
Posts: 28
Joined: Sat Aug 01, 2015 2:45 am
Location: South Africa

Re: Some GPIO pins not working - PIC damaged?

Post by wave.jaco » Thu Oct 13, 2016 11:34 pm

I can totally associate with you on that! I also always include an initialization routine as the first function call in main() which configures all the TRISx, PORTx and analog registers (among others) to what I need them to be, regardless of what the datasheet says the default values are on startup. I have spent way too much time debugging to only find out I have made the silly mistake of assuming a certain register bit would have a certain value.

Thanks for the help, Bill! Much appreciated!

Post Reply