> For the complete documentation index, see [llms.txt](https://tk233.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tk233.gitbook.io/notes/stm32/timers/tim.md).

# Using TIM on STM32

## Timer TRGO Events

<figure><img src="/files/ELgHlu0MxGyFxplAlnpT" alt=""><figcaption></figcaption></figure>

#### Reset

This is rarely used. Software control of the slave device is preferred.

#### Enable

This is rarely used. Software control of the slave device is preferred.

#### Update Event

This event is generated when counter overflows or underflows.

#### Capture Compare

This event is generated when the counter is equal to the channel pulse value. Think this as the PWM signal.&#x20;

However, note that when using "Active level on match" or "Inactive level on match", it will only generate one trigger event on TRGO and will not be reset.

## Repetition counter settings

<figure><img src="/files/Da4GM7TIF43b0ReVRVh2" alt=""><figcaption></figcaption></figure>

## PWM generation mode

### To Drive Active Low LEDs

set CH Polarity to Low.

<figure><img src="/files/yisk5KLhUZoxY0spPIJU" alt=""><figcaption></figcaption></figure>

Do not change PWM Mode. The internal logic is still operating in "PWM mode 1" mode.

> e.g. Setting CCR to 0 makes the channel always inactive, while setting CCR to ARR makes the channel always active.

<figure><img src="/files/M7NYklDo8YVsBHmgLYO1" alt=""><figcaption></figcaption></figure>
