Fosc / 2 on Mega163

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

Can anyone verify that you can get the oscillator frequency / 2 from the OC2 pin using Timer 2. I have a project that is migrating from a 8515 to a Mega163 and have Timer 2 available. You could do this on the PIC timer counters, but I havn't tried on the AVR.

Mark Senior

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

I can, and I can give you the recipe:

OC2 = 0x00; // (Same as the reset value)
TCCR2 = (1 Toggle on compare, Clear Timer on Compare match, prescaler = 1.
OC2_DDR |= (1 Set data direction bit as output.