CTC timer question

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

I am using the ATMEGA328P datasheet for my question.  I understand that the CTC timer will reset the timer on a match, but it seems from the datasheet this only happens on value OCRA.  (Table 19-9 mode 2) If I were to also use OCRB could I also trigger that interrupt, Timer/Counter0 Compare Match B, as long as the match value for OCRB was less than OCRA.  I am thinking that the B timer would trigger at the lower value but the timer keep on going until it "matched" the higher value and then reset.  I would suppose this is why you can't have 2 CTC values on the same timer because both can't be used to reset.  I assume also that were I to use the CTC timer but had a value of OCRB > OCRA then it would simply never be reached and nothing would happen.

 

I hope this doesn't seem a lazy question.  I know I could simply try it, but the responses I get here are often quite enlightening and teach me more than I would simply learn by roughing out my own ideas.  Thanks in advance for the help.

This topic has a solution.

Andrew

Last Edited: Thu. Jan 25, 2018 - 03:42 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sounds like you understand it correctly!

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Great.  Thanks.  It must be a first.  I am getting better at all this!  :)

Andrew

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

 

I have also used Timer1 in one of the PWM modes where ICR1 is used for TOP and both OCR1A and OCR1B are generating interrupts...

And I was not doing any sort of PWM.

 

David (aka frog_jr)

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

theaddies wrote:
I would suppose this is why you can't have 2 CTC values on the same timer because both can't be used to reset.

As David hinted at, have you looked at mode 12 CTC with ICR1 as TOP?

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

Interesting.  Thanks guys.  I always learn something.

Andrew