Dtynin
Dtynin
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?
4 replies