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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tk233.gitbook.io/notes/stm32/timers/tim.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
