ATMega16 Output Compare Question

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

Hello-
I'm trying to setup output compare to generate a interrupt ever 500ms or a half a second.
I'm using a ATMega16 and a 6.00Mhz crystal.

This is the code I have its seems like it generates a interrupt ever 4 secondes... I'm using prescaler of 64.
r16 temp
r17 temp2

ldi temp, 1<<OCIE1A ;oc1a interrupt on
out TIMSK, temp
ldi temp, (1<<WGM12)+(1<<CS11)+(1<<CS10) ;mode4
out TCCR1B, temp
ldi temp2, 0xB7 500ms per avrcalc 6Mhz.
ldi temp, 0x1a
out OCR1AH, temp2
out OCR1AL, temp
Is this correct? Any comments?
Thank you
Don

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

If you thought you were running on the external crystal, but were actually running on the default internal oscillator (default fuse settings), you would get 3 seconds between interrupts.

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

Hi
Ok I didn't make any changes to fuses. This is the first project using atmega16. I will check out the data sheet.
Thank you
Don

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

Quote:
Ok I didn't make any changes to fuses.

Then you are running on the internal oscillator.

Data sheet page 23, Default Clock Source.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Hi
That did it! Running correctly now.
Thanks again.
Don