3
\$\begingroup\$

I am currently working an Atmel micro controller, the EVK1104S, which has the UC32 Data Sheet. We have actually planted this chip on a custom PCB and are in the process of writing more firmware.

Currently, I need to tell the ADC on the Micro Controller Unit(MCU) to sample at 8k samples / second. In reality this is for sampling a microphone. Either way, the documentation is quite unclear (from my perspective) and I was looking for some clarification.

I know that to change the sampling rate I need to change what is called the Mode Register, the register used to configure the ADC for use (pg 799 in the link above). This is the register which allows me to modify the ADCclock.

Example (from pg 799):

ADCClock = CLK_ADC / ( (PRESCAL+1) * 2 )

From what I gather, I will only need to change the PRESCAL to make the ADCClock operate at 8Khz. The problem is that PRESCAL is limited to 8 bits of resolution.

For example, if the controller is set at 12Mhz/x = 8Khz then x would need to be 1500. Because x is limited to 8 bits as I said before this would appear to be impossible, because the max is 255.

I feel that I am doing something wrong here, or not understanding what the datasheet wants me to. Can anyone confirm what I have just talked about or help direct me?

Basically, how can I specify the ADCclock to run at 8KHz if the PRESCAL is only an 8 bit value assuming the CPU is running at 12MHz?

\$\endgroup\$
3
  • \$\begingroup\$ I don't know that line of micros, but it sounds like that is the bit conversion clock, not the sample clock. \$\endgroup\$ Commented Apr 8, 2013 at 20:37
  • \$\begingroup\$ Identical post, I think, with one upvoted answer at the moment on stackoverflow. I removed the ATmega tag, since this uC is not in the ATmega family. Please add back if that's an error on my part \$\endgroup\$ Commented Apr 8, 2013 at 21:11
  • \$\begingroup\$ This question belongs here, not on SO. But if the OP crossposted it we should close both to teach him a lesson. \$\endgroup\$ Commented Apr 8, 2013 at 21:23

1 Answer 1

2
\$\begingroup\$

Your misunderstanding lies in the fact that "ADCClock" is not the "sampling rate", it is the internal clock with which the ADC module on the microcontroller works:

"Converting a single analog value to a 10-bit digital data requires sample and hold clock cycles as defined in the Sample and Hold Time field of the Mode Register (MR.SHTIM) and 10 ADC Clock cycles." (section 29.6.1, p. 792)

In other words, to get a single sample from your ADC requires actually quite a few (a minimum of 13 if my cursory read of the data sheet is correct) ADC clock cycles, and not just one. Your sampling rate is simply a function of how (often) you trigger a conversion (section 29.6.5). For this you would probably use one of the timer modules, which will most likely give you more flexibility in the actual intervals so you can achieve your 8kHz target rate.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.