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.
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.
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.
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.
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