timers, capture & output

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

Hi everyone.

I have a couple of questions/clarifications for a project I'm working on, it's in relation to timers on mega644p (or megaxx4p really)

Only Asynchronous timers with register ASSR can be clock from an oscilator on TOSC1 eg timer/counter 2 on mega644P (timer/counter 0&1 run off main system clock), correct?
Also why is 32.768kHz crystal so popular on TOSC1 TOSC2 (I read its optimised for 32.768 kHz)?
Is it because it offers a slower clock? can the UART also reference it?

Can a timer/counter perform 2 modes of operation at once, ie can timer/counter1 (the only counter w/input capture unit) perform PWM output and input capture?
I'm assume this isn't possible as some modes of operation (modes 8, 12, 14) utilise the input capture register ICRn, but on the other hand i wonder if I use other modes of operation which do not use ICRn will it be ok?
Has anyone tried this?

And finally... ;)
If I want to drive 2 DC motors using the same counter timer (say timer/counter1) using pins OCA1 & OCB1 would the best way be to use one of the many PWM modes (but not modes 9, 11 or 15 which use OCRnA as top)?
could I use input capture while performing this type of PWM? providing I do not use mode 8, 12, 14, 9, 11 or 15 for reasons stated above.

thanks for your help
~Andy

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

Yes, Timer 0 & 1 run off the main clock while Timer 2 has the option of running on an external crystal. The reason that 32.768kHz is used for Timer 2 is that it is optimized to be a real-time clock (RTC) in a deep sleep mode. 32768 Hz is a popular choice because it is easy to count that in binary so that after 2^15 ticks the RTC code can increment one second.

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

Quote:
Can a timer/counter perform 2 modes of operation at once, ie can timer/counter1 (the only counter w/input capture unit) perform PWM output and input capture?

In PWM modes that do not use the ICR register, it should still functional with input capture (though I have never tried it).

Regards,
Steve A.

The Board helps those that help themselves.

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

thanks kmr & Koshcci for your feedback.
I think the more i go over it I tend to think I should be able to do PWM and input capture at the same time as long as I choose the right mode as mentioned.
Has anyone implemented this?