0
\$\begingroup\$

I'm using a Microchip PIC24FJ1024GA606.

I have two versions of my PCB and I am using a pin to identify the hardware revisions. On Version 1, the pin is unused and on version 2, the pin is connected to a 4k7 pull-up to 3v3.

In the code itself, I am using IOCPDGbits.IOCPDG8 = 1; to set the port as a pull down. This allows me to identify version 1 boards as having that pin low, and version 2 boards as having the pin pulled high.

Everything was working for a week or so and then it stopped working -- my version 2 board started to register the pin as low. I replaced the resistor and once again it was reading low. I then replaced it with a 2k ohm resistor and now the pin is reading high.

My questions are:

  1. Am I doing something obviously wrong?
  2. What are the chances the MCU is damaged?
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Did you measure the voltage at the pin in both cases? \$\endgroup\$
    – Bryan
    Jul 6, 2022 at 17:53
  • \$\begingroup\$ 1.8v with the 4k7 and 2.7v with the 2k @Bryan \$\endgroup\$
    – t3ddftw
    Jul 6, 2022 at 17:56
  • 2
    \$\begingroup\$ The resistance value of the internal pulldown has a wide tolerance and isn't super low, so a 4.7K is too weak to ensure a high. So your solution is the right direction. You may even have to go lower to guarantee a valid high. Either consult the datasheet for a min pulldown value spec and calculate a safe value, or just make it 0-100 ohm and be done with it. \$\endgroup\$
    – td127
    Jul 6, 2022 at 18:03

1 Answer 1

1
\$\begingroup\$

Your pull up resistor was too weak, and the resulting voltage was in the gap between logic high and logic low, refer to the snip from thei pic24 datasheet below:

[1]: https://i.sstatic.net/r0Rlx.png

It is very unlikely you damaged the pin with the weak pull up. You can use a stronger pull up to get a voltage within spec of the pin's high level.

The 2k you have is currently running at 81% vdd, however if another chip has a higher sink current you’ll be back in the danger zone. A 1k pull up would be more adequate (0.5V drop at 500uA - 2.8V at the io pin = 84%)

(snip from datasheet @ https://ww1.microchip.com/downloads/aemDocuments/documents/MCU16/ProductDocuments/DataSheets/PIC24FJ1024GA610-GB610-Family-Data-Sheet-DS30010074G.pdf)

\$\endgroup\$
4
  • \$\begingroup\$ Never mind, I see your edit. Thank you! ~Not to be spoon-fed too much, but when I originally went over this table, I understood that I needed a minimum of 0.8v to register the pin as high. 4k7 with 400uA of pull is around 1.8v, which I thought was enough. How should I calculate a better value? I am tempted to throw 100ohms at it, but would like to use a real calculation.~ \$\endgroup\$
    – t3ddftw
    Jul 6, 2022 at 18:20
  • 2
    \$\begingroup\$ @t3ddftw there’s the problem, it’s not 0.8V, it’s 0.8*Vdd, as in 80% of the supply voltage. This is different from other logic families that can have logic thresholds independent of Vdd (families I am unable to name off the top of my head mind you, but I’ve seen them before) \$\endgroup\$
    – Bryan
    Jul 6, 2022 at 18:22
  • 1
    \$\begingroup\$ Aha! That's what I was missing. Thank you so much! \$\endgroup\$
    – t3ddftw
    Jul 6, 2022 at 18:26
  • 1
    \$\begingroup\$ @t3ddftw anytime. Also do make sure you see my edit to the answer near the bottom where I calculate that your 2k resistor probably won’t hold up under tolerances. \$\endgroup\$
    – Bryan
    Jul 6, 2022 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.