Does using PWM cause latency on the rest of the code?

Hi All,

I'm looking to utilize the Arduino Due's 12 PWM pins (pins 2 to 13) for a couple RGB LEDs. I need a 12-bit resolution to match the TLC5940's resolution (used in another part of the project). The values of the PWM will not be changing often; maybe a change to the values once every couple of seconds.

As I don't know much behind the way PWM works, I'm wondering if this will cause a delay on the rest of the code, to always have 12 pins sending square waves to the LEDs. I obviously ask because the code I have is very time-sensitive and any delay is non-desirable. If so, I'll have to go with Plan B which is using a TLC5940 to control the LEDs instead.. But because there's less info on tlc5940 + DUE, I'd like to not go down that route.

Any help is greatly appreciated, thanks!

Pat

Nope, no delay on the rest of the code - that's the beauty of hardware PWM (you can also do PWM in software, by triggering an interrupt from a timer, and twiddling the pins in the interrupt - this is how servo library works, for example - that technique can also get you PWM on pins that don't have hardware PWM, etc). The timer runs, and it's output compare module toggles the pin based on the value of the timer, all without taking any time away from executing code.