# Using TIM on STM32

## Timer TRGO Events

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2FVkdfeesmjxJMr84xgzc4%2Fimage.png?alt=media&#x26;token=0bbc6a3d-85c7-43ae-8b78-52a57d7c46e4" 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="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2FagTJxrrCmPK0kDN07ftg%2Fimage.png?alt=media&#x26;token=08caaabc-ede3-461f-b6e2-46e9963e395a" alt=""><figcaption></figcaption></figure>

## PWM generation mode

### To Drive Active Low LEDs

set CH Polarity to Low.

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-07f8b13e5334d3c77686535c5d39bd221ad6992f%2Fimage.png?alt=media" 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="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-0b6200ce7a1d57d145f30675607616d0e1091892%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>
