Skip to content

Commit

Permalink
Add timer update event
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrVin committed Nov 8, 2020
1 parent 54e6416 commit 3500d64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions labs/07_timers_inp_capture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ LL_TIM_IC_SetPrescaler(TIM2, LL_TIM_CHANNEL_CH1, LL_TIM_ICPSC_DIV1);
LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH1);
```
Необходимо записать бит UG регистра EGR. Это вызывает Update event что приводит к тому, что таймер принимает значение из теневого регистра. Без данной операции первый цикл счета до обнуления будет выполнен со значением prescaler по умолчанию.
```C
LL_TIM_GenerateEvent_UPDATE(TIM2);
```

И снова нужно включить прерывание. Обратите внимание, что тут прерывание возникает именно по событию на канале 1 `CC1`, а не по обновлению таймера `UPDATE`, как в прошлом проекте.

```C
Expand Down
1 change: 1 addition & 0 deletions labs/07_timers_inp_capture/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static void timers_config(void)
LL_TIM_ACTIVEINPUT_DIRECTTI);
LL_TIM_IC_SetPrescaler(TIM2, LL_TIM_CHANNEL_CH1, LL_TIM_ICPSC_DIV1);
LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH1);
LL_TIM_GenerateEvent_UPDATE(TIM2); // reset timer to force it to our setting
LL_TIM_EnableIT_CC1(TIM2);
LL_TIM_EnableCounter(TIM2);
/*
Expand Down

0 comments on commit 3500d64

Please sign in to comment.