Timers

The general purpose timer

This peripheral allows us to count up to a value and then generate an Interrupt ReQuest (IRQ) which then triggers the execution of a corresponding Interrupt Service Routine (ISR). There are actually many other modes of operation which you can read about in the datasheet.

.

Timer feature comparison

timers

.

TIM2, TIM3, TIM4, TIM5, TIM6, TIM7, and TIM12 connected to the APB1 domain.

TIM1, TIM8, TIM9, TIM10, and TIM11 connected to the APB2 domain.

.

Driver stm32f4xx_tim :
– stm32f4xx_tim.h
– stm32f4xx_tim.c

.

stm32f4xx_rcc.c have also to be included in the project.

.

Watchdogs

Independent watchdog  IWDG
The independent watchdog is based on a 12-bit downcounter and 8-bit prescaler. It is clocked from an independent 32 kHz internal RC and as it operates independently from the main clock, it can operate in Stop and Standby modes. It can be used either as a watchdog to reset the device when a problem occurs, or as a free-running timer for application timeout management. It is hardware- or software-configurable through the option bytes.

Window watchdog  WWDG
The window watchdog is based on a 7-bit downcounter that can be set as free-running. It can be used as a watchdog to reset the device when a problem occurs. It is clocked from the main clock. It has an early warning interrupt capability and the counter can be frozen in debug mode.

SysTick timer  RTC

This timer is dedicated to real-time operating systems, but could also be used as a standard downcounter. It features:
– A 24-bit downcounter
– Autoreload capability
– Maskable system interrupt generation when the counter reaches 0
– Programmable clock source.

.

TIM1 & TIM8  introduction

The advanced-control timers (TIM1&TIM8) consist of a 16-bit auto-reload counter driven by a programmable prescaler.
It may be used for a variety of purposes, including measuring the pulse lengths of input signals (input capture) or generating output waveforms (output compare, PWM, complementary PWM with dead-time insertion).

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Leave a comment