Go Down

### Topic: Return the actual ADC clock (Read 1 time)previous topic - next topic

#### pedrolopes746

##### Aug 17, 2013, 10:55 am
hello

the following function return the actual ADC clock:

Parameters:
ul_mck -    Main clock of the device (in Hz)

{
uint32_t ul_prescal;

/* ADCClock = MCK / ( (PRESCAL+1) * 2 ) */
ul_adcfreq = ul_mck / ((ul_prescal + 1) * 2);
}

could someone give an example of application

#### Palliser

#1
##### Aug 17, 2013, 02:52 pm
Hola pedrolopes746,

As you mentioned in your post, the routine returns a clock value. For the Arduino Due case this value in Hz is 21000000. Four times smaller of the main clock, normally, 84MHz.

The calculation of the ACD clock frequency is very simple:

Quote
ul_adcfreq = ul_mck / ((ul_prescal + 1) * 2);

where          ul_mck is the main frequency of the board = 84000000
ul_prescal is a 32-bit clock prescaler set to 1 (0xffu <<

Here a raw example sketch for Due:

Code: [Select]
`int ACTUAL_ADC_CLK;void setup() {  Serial.begin(9600);}void loop() {  // get and print current ADC clock (in Hz):  ACTUAL_ADC_CLK = adc_get_actual_adc_clock(ADC, SystemCoreClock);  Serial.println(ACTUAL_ADC_CLK);  while (1) {}}`

The output:

Quote
21000000

Regards!

#2