Capture and Compare PWM - Arduino board

Hello guys.
Is there a way to create an interruption every edge of your PWM singnal output from Arduino? I know that in the PIC microcontroller there is the CCP module (capture and compare PWM), which, in your PWM generated signal from output channel, each edge change (can be falling edge, rising edge....) a separeted module interrupts and go to a interruption fuction. So I need to know if it is possible on arduino and if yes, how to implement this.
to be clear, I´m not trying to use internt routine interruptions that generated PWM, or use other extern interrupts to get the signal, I need to know if arduino can creat interruptions based on their own generated PWM sinal.

Thanks :smiley:

Yes. It is possible.
Well, I don't know what to use it for.

1 Like

ok, being possible is the first step. In the truth, this is used to emulate a incremental encoder, because in my project it is unimplemented. thank you so much, lets see if other person have more clues.

Arduino PWM is created by a hardware timer.
The hardware timer has an overflow interrupt and a comparison match interrupt, and the PWM output has uses that edge of timing, so it inevitably matches.
By the way, millis in Arduino counts up using the timer interrupt used in combination with it's PWM.

1 Like

:frowning: sad. I need to control the pwm and timer separeted, as CCP modulo does. Ok thank guys

I'm confused.
Isn't operating PWM meant operating a timer?
The AVR timer basically works the same as the PIC's CCP module.
The value set for the PWM edge can be used as an interrupt trigger point as it is.

1 Like

so my doubt is if is possible to set a independent frequency to pwm (using one interruption), and each edge changing from pwm signal, to create an interruption (other interruption separated from the first) to count the pulses.

You may have misunderstood a little.
No interrupts are used to generate PWM.
PWM is automatically generated by the hardware.
And "additionally" you can also use interrupts.

is, and my question is: this PWM generated by hardware can generate an interruption associated with this edge changing?

You can use the overflow and compare match interrupts to generate the rising and falling edge of the signal.

The overflow corresponds to the rising edge, and the compare match for the falling edge using the default PWM configuration and enabling those two interrupts

That's what I've been saying. #4

1 Like

ok, but how does it? what librarie or funtions may I use?