We're having a problem using the ADC of the ADMC401. It's very odd, because we use it in a number of products, but this is the first time I've had to dig into the ADC code so closely before. We've had to troubleshoot a bit of the hardware, but we're not sure if there are still some hardware issues. We've tested enough to conclude that the ADC is are point of trouble.
The ADC settings we're using:
- Internal voltage reference of +2 Volts from the Vref pin
- Simultaneous sampling
- Internal triggering from a 50 kHz PWM
For debugging purposes, I have a program that has a main loop that takes the most recent raw reading from channel 0 of the ADC (VIN0 pin / ADC0 register) and sends a value out to a 12-bit DAC that generates a 0-10 Volt output, every 16 ms. Now, I've put constants in the program to output given voltages on the DAC output, and I can generate any output I want - so the output side of things seems solid and working.
The inputs to the ADC pins seem noise free too. But as soon as I start taking data from the ADC to update the DAC during the ADC_ISR, it looks like I get garbage data. On an unused pin that is being held at the Vref of +2V, the ADC data seems to be 0 most of the time (not the expected 2,048) and it spikes up to 4,095 frequently.
On our intended input, I can put a voltage in with a variable supply. Starting at +2V, the output of the ADC is zero. At slightly below +2V it starts rapidly switching between 0 and 4,095. At about +1.8 V and below the ADC reports 4,095.
Now, to further ensure that the DAC output is getting the raw ADC data, I also added a dump of the raw 12-bit ADC data dumped onto the 12-bit PIO data pin bus. I'm using a logic analyzer to confirm the same ADC result.
To further confirm the results, I put the ADC into Gain Calibration mode. In this mode, the ADC seems to somewhat work oddly enough. Starting with a 0 Volt input to the GAIN pin, the ADC reports 2,048. As I increase the GAIN voltage to +2 Volts, the ADC rises from 2,048 to 4,095. Going above +2 V on GAIN, the ADC value rolls over to 0, and as I continue to increase the GAIN to +4 V, the ADC rises up to return to 2,047. The ADMC401 spec sheet doesn't really specify if this is correct behavior of the Gain Calibration mode, but at least I'm getting a full-scale sweep of sorts for a 0-4V sweep of the GAIN input. The logic analyzer backs up all the readings. Is this correct behavior of Gain Calibration mode?
In Offset Calibration mode, I'm getting a continuous ADC reading of around zero. I wasn't sure if that should be zero or 2,048?
The circuit is intended to follow the spec sheet for the most part. I noticed that this board doesn't have the larger tantalum 10 uF cap across CAPB and CAPT, though it does have the smaller 0.1 uF between them. The 0.1 uF caps from CAPT and CAPB to ground are in place, as well as the 0.1 uF cap from Vref to common. The 10 uF from Vref to common is missing too though.
Vref does appear to be +2 Volts, and CAPB and CAPT are measuring +1.5 V and +3.5 V, a difference of 2 which indicates the ADC should be ready to measure, but are these values correct?
I also measured the PWMSYNC signal to make sure that that ADC sampling rate was 50 kHz.
Oh, we have had issues with ADMC401's burning out before on other devices, so we did try replacing the chip on the board too, but that didn't fix it.
I don't see how I could have something misconfigured in software as there really isn't a whole lot to set in the ADMC401 ADC setup, and my code is based on code from previous programs at my company which I've modified for many products over the years. Is there something I could be missing there though? Or is it likely a hardware problem, perhaps a pin not touching a pad (wouldn't be the first time on these boards)?