Why Is My AVR32UC ADC Returning Zero Despite a Correct Input Signal?

Hey everyone, I'm currently working on reading an analog value using the ADC on my AVR32UC microcontroller, but I'm running into a problem where the ADC consistently returns zero, even though the input signal is correct. I've verified that the ADC driver is enabled in the prj.conf file, and also ensured that the ADC channel being used corresponds to the correct pin on the microcontroller. Here's the code I'm using:
#include <zephyr.h>
#include <device.h>
#include <drivers/adc.h>

#define ADC_CHANNEL 1
#define ADC_DEV "ADC_0"

void main(void) {
const struct device *adc_dev = device_get_binding(ADC_DEV);
struct adc_sequence sequence = { .channels = BIT(ADC_CHANNEL) };
adc_read(adc_dev, &sequence);
}
#include <zephyr.h>
#include <device.h>
#include <drivers/adc.h>

#define ADC_CHANNEL 1
#define ADC_DEV "ADC_0"

void main(void) {
const struct device *adc_dev = device_get_binding(ADC_DEV);
struct adc_sequence sequence = { .channels = BIT(ADC_CHANNEL) };
adc_read(adc_dev, &sequence);
}
The issue I’m facing:
error: Failed to get binding for ADC device
error: Failed to get binding for ADC device
Despite these efforts, the ADC still returns zero consistently. Does anyone have suggestions on what might be causing this, or how I can troubleshoot further?
Solution:
@Dtynin It seems like your ADC isn't working because the binding for the ADC device isn't found, and your ADC configuration might be incomplete. Check your device binding and sequence configuration
Jump to solution
2 Replies
Solution
Enthernet Code
Enthernet Code4mo ago
@Dtynin It seems like your ADC isn't working because the binding for the ADC device isn't found, and your ADC configuration might be incomplete. Check your device binding and sequence configuration
Dtynin
Dtynin4mo ago
Hey @Enthernet Code , you were right. I checked the ADC device name in the device tree and found a mismatch. Fixing that sorted out the binding issue. I also tweaked the adc_sequence configuration, and now the ADC is reading values correctly. Thanks a ton
Want results from more Discord servers?
Add your server