Setting up timer for ADC conversion trigger

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've been working with the ATMEGA324P-20AU to read some data over SPI from five ADCs that are triggered (all at the same time) by a conversion pin. The conversion pin of each ADC is wired to one pin of the ATMEGA.

I would like to have the ATMEGA trigger each conversion at an adjustable rate between 1 Hz and 1 kHz. The conversion rate is adjustable in software. I would like to achieve at least 0.1 Hz resolution.

I've noticed that the ATMEGA324P-20AU has an external pin (TOSC1) that can accept an input from an external oscillator.

If I am to use the 16-bit timer of the AVR, and the main processor clock is 18.432 MHz, could someone suggest:

(1) The clock frequency that I should input to the TOSC1 pin using an external oscillator.

(2) Which pin should I use as the conversion pin for the ADCs? One of the OCnA or OCnB pins?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Those rates are fairly slow (in microcontroller terms). Merely use one of the AVR's timers to "trip" between 1ms and 1000ms, and do the work in a simple ISR. 16-bit timer1 will have more "reach" and perhaps make the code simpler.

No need for an external clock for this purpose.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That sounds good; thank you very much for pointing me in the right direction, theusch! I am more familiar with simple ISRs than with the use of an external clock, and I agree that this will make the code much simpler.