|
Hello All,
I am attempting to write a simple adc polling function (the atmel examples use interrupts which I don't want to use), and it's not working. Here's essentially what I am doing
<code> uint32 adc_get_data(uint32 channel) { uint32 data; ADC_EnableChannel(AT91C_BASE_ADC, channel); ADC_StartConversion(AT91C_BASE_ADC); while((adc->ADC_SR & (1 << channel)) != (1 << channel)); // wait for conv to finish
data = ADC_GetConvertedData(AT91C_BASE_ADC, channel); ADC_DisableChannel(AT91C_BASE_ADC, channel); return data; }
int main() { /** all inits and configs **/ while(TRUE) { data = adc_get_data(ADC_CHANNEL_5); printf("%d\n\r", data); // serial dbgu port configured } }
</code>
However, on the serial port, I'm reading all zeros. what am I doing wrong?
I appreciate your help!
|