AT91SAM3S4 ADC_EnableChannel is not working properly

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

Posts: 12
Joined: Mon Aug 08, 2011 5:59 pm

AT91SAM3S4 ADC_EnableChannel is not working properly

Sun Nov 27, 2011 11:42 am

We're working on AT91SAM3S4 board, and we're trying to use the ADC channel enable function provided in adc.h:

#define ADC_EnableChannel( pAdc, channel ) { \
assert( channel < 16 ); \
(pAdc)->ADC_CHER = (1 << (channel)); \

Currently, while running this, the channel is not set properly without a delay after the function ADC_EnableChannel.
we read the status on ADC_CHSR, and sometimes the value changes. only the delay solved the issue for us.
However, we didn't find any reference for needing a delay after that.
Can someone maybe give us some insight about that ?

here's our code:

/* Clear the VREF of the ADC Pin - actually it's set.*/

/* Enable peripheral ADC clock because now the SLEEP option not work O.K.*/

// enable channel to check voltage
ADC_EnableChannel ( ADC, channel );

Delay(100); // Don't remove this because the channel is not stable
// dummy read to clear EOC flag in ADC_ISR
pAdc->ADC_CDR [channel] ;

ADC_StartConversion (pAdc);

while ( ( pAdc->ADC_ISR & (1 << channel) ) == 0 );

result = (word) ADC_GetConvertedData ( pAdc, channel );

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 2 guests