Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: AT91SAM3S4 ADC_EnableChannel is not working properly
PostPosted: Sun Nov 27, 2011 11:42 am 
Offline

Joined: Mon Aug 08, 2011 5:59 pm
Posts: 18
Hey.
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.*/
PIO_Clear(pin_vref);

/* Enable peripheral ADC clock because now the SLEEP option not work O.K.*/
PMC->PMC_PCER0 = 1 << ID_ADC;

// 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 );


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: