Does overflow interupt get triggered with phase-correct PWM?

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

Can anyone tell me if I can use overflow interrupts on a counter that's being use for phase correct PWM? This might be a dumb question, but since (as I understand it) the counter counts down instead of rolling over to min when it hits max, I thought it was worth asking.

I don't expect this would be chip-specific, but in case it makes a difference I'm using an ATmega8535.

I'm using both of the 8bit counters for two independent PWMs and I'd like to also set a regular heartbeat-style interrupt to take care of basic chores (e.g., compare actual motor speed to target and adjust PWM duty cycle).

To be honest, I'm not sure if I want to use the 16-bit timer instead to establish this "heartbeat" as I haven't thought through the timing to see which would happen at an appropriate frequency. But I was hoping someone could tell me if the 8bit timer was at least an option.

I do anticipate that the same timer running the PWM would be WAY too frequent to adjust the duty cycle based on feedback, so I expect I'd want my interrupt routine to only do real work say 1 out of every 256 times it is called (yes I know that duplicates the 16bit timer). BTW I need to run the 16bit timer with no prescaling (I think) because I'll be using it to calculate RPM and I'd like the resolution.

Sorry for ALL the detail, but I included it in case someone had any other advice.

Thanks!
-Tim

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

Quote:
Phase Correct PWM Mode

The phase correct PWM mode (WGM01:0 = 1) provides ...
The Timer/Counter Overflow Flag (TOV0) is set each time the counter reaches BOTTOM.
The interrupt flag can be used to generate an interrupt each time the counter reaches the BOTTOM value.

Lee

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

Thanks Lee!

If that was from a datasheet, sorry I didnt' find it myself. If it was from some other useful source of info, please let me know which.

-Tim

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

Yup, the Mega8535 datasheet. I remembered seeing it in some datasheet when doing the recent "0% duty cycle PWM" topic. I searched it out in the Mega8535 sheet.

Lee

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

Thanks. I guess it's the old advice, when all else fails, read the instructions!
Thanks again!