Electronics > Projects, Designs, and Technical Stuff

microcontroller timers explination

(1/4) > >>

drakejest:
hello i am in need of a quick crash course about timers. for intents and purposes i am concerned about the rp2040 timers to create a PWM signal and timer interrupts. I am more concerned about the concepts rather than actual code on how to execute it.

First questions when generating a PWM signals, are the toggling of the pins independent of the processor?  if the processor is running a task, that task will never be interrupted to toggle the PWM, meaning a pheripherral is doinng the toggling after its being set.

I have noticed on that the alt functions it would seem that a timer could have subchannels what does it mean? for example in the rp2040 GPIO 0 is PWM0 'A' and GPIO 1 is PWM0 'B'. what does the letter denotes and what could be the reason why there are subchannels? since they are both tied to the same timer does that mean that if activate the PWM of GPIO0 and GPIO1 they could not have different PWM frequency as they are tied to the same timer. Or that just means they can have different frequency but the clock pulses are synchronous because the source from the same timer. For the RP2040 there seems to be only 2 subchannels for each timer, but for other microconntrollers like the SAMD21 there could be more,

Speaking of SAMD21 they feature TCC or Timer/Counter for Controls ontop of the base T/C or timer/counters. How is TCC different from Tc?

Thank you for answering my questions :)

jpanhalt:
Yes, the timers run independent of the MCU.  However, what you do with that fact doesn't.

drakejest:

--- Quote from: jpanhalt on September 24, 2021, 07:44:45 pm ---Yes, the timers run independent of the MCU.  However, what you do with that fact doesn't.

--- End quote ---

ahh so that means for every change state of the PWM signal the mcu gets interrupted and will have to flip the bits, is this right?

Kleinstein:
The PWM runs independent and sets / resets the output pins. The 2 subchannels to a timer can generate 2 PWM signals with different PWM ratio, but the same frequency and usually with a fixed phase.

In addition to the PMW signal one can (but just for PWM no need to do so) also generate an interrupt signal.

drakejest:

--- Quote from: Kleinstein on September 24, 2021, 08:31:17 pm ---The PWM runs independent and sets / resets the output pins. The 2 subchannels to a timer can generate 2 PWM signals with different PWM ratio, but the same frequency and usually with a fixed phase.

In addition to the PMW signal one can (but just for PWM no need to do so) also generate an interrupt signal.

--- End quote ---


Is it possible to synchronize timers? for example for some odd reason, i need two pwm signals but im left with pins that are on different timers, so is it possible to spit out a for let say 1000 Hz 50% duty cycle on different timers that are synchronized?

another thing what if i want two PWM signals but the other one is an inverted copy of the first one? should that be done on the same or separate timers?

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version