3 ms·
Regarding the ADC issue specifically, when programming at the hardware level never discount the simple possibility that it's just that the microcontroller pin i
by phaedrus 10y ago
Regarding the ADC issue specifically, when programming at the hardware level never discount the simple possibility that it's just that the microcontroller pin is fried (e.g. due to ESD). Also consider the opposite: the ADC is telling the truth, and there really is 0 volts. (In other words connect a multimeter or scope to the pin while changing applied voltage.)
There's also often mask/state/flag bits that can affect these things. Maybe the ADC is in differential mode whne you expected absolute, etc.
If I eliminated the easy possibilities and was stumped more than an hour, I'd go all the way back to a new/blank chip and whatever "My First ADC Demo" program Microchip supplied, possibly building it on a breadboard instead of the circuit board. If your real board can't start up without the rest of the project code, I would just frankenstein the breadboarded microcontroller on top of the soldered-in one. (E.g. connect ground and ADC lines only and see what the demo program reads there.)
Whether we're talking about mocks and unit tests for a web service, or hardware hacking, the process is the same: iteratively asking "How can I ensure I'm testing only one variable?"