XMEGA TIMER different frequencies for the CCA-CCD pins

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

I am using an XMEGA384C3, and I can change the frequency of the timer to generate different square waves of the same frequency, but different duty cycles for the CCA, CCB, CCC, CCD pins. However, is there a way to use a single timer to output different square waves of different frequency and duty cycle, or do I have to use separate timers. 

 

The closest thing I can come up with is using a timer in FRQ generation mode and changing the frequency on the fly, but it only outputs on CCA. I would like to have different square waves simultaneously.

 

For example,

 

output a 4HZ square wave on TD0 (CCA), and a 2 HZ square wave on TD1 (CCB).

 

Thanks

Last Edited: Sat. Apr 29, 2017 - 01:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Greetings -

 

You cannot readily generate simultaneously two frequencies from one timer. Thats not just an AVR thing. Its the way timers work. 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

How high a frequency are you planning on using?

How much other work must the micro do while generating the waveforms?

 

2 Hz and 4 Hz are very low, (i.e. slow), frequencies compared to an Xmega running at 32 MHz.

 

You could easily have a timer/counter generate an interrupt at 8 Hz, (double your 4 Hz frequency), and within the ISR toggle two output pins high and low as needed, for the 4 Hz and 2 Hz waveforms.

 

There would be fractional uSec offsets and jitter in the signals,  which might not matter, depending upon your project's needs.

 

Know also, that if you always need an F and F/2 output, the XmegaE5 series, (e.g. Xmega32E5), has a programmable logic module, so you could feed it a square wave of 4 Hz, run it trough a Flip Flop, and output your 2 Hz signal.

 

JC

 

Edit: Typo

Last Edited: Sat. Apr 29, 2017 - 10:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Especially at low frequencies where the ISR servicing can be tolerated, then each channel can have a compare match, toggle pin on compare match, and trigger an ISR to set the next compare match value.  Often called "leapfrog" in prior discussions.

 

I'm not very conversant in Xmega vs ABR8 so I can't give chapter and verse.

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.