Output Compare

Ein Output soll nach einer bestimmten Zeit togglen.

Image1

Image2

/* USER CODE BEGIN 2 */

  HAL_TIM_OC_Start_IT(&htim1, TIM_CHANNEL_1);

 

  /* USER CODE END 2 */

PWM

Duty cycles: D = T over P cdot 100 "%" where T is the pulse duration and P  the period of the PWM signal

Clock System

LL (low level)  Functions

Bild1

Bild2

  1.  

  2.  

GPIO alternate function (AF) configuration

Pinout

  1. Enable the peripheral clock of GPIOs
    Which clock? See Datasheet "CLOCK TREE" and "APB2 Peripheral Clock Enable Register"

    Functions start with LL_APB2_   …  use auto completion
    LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);

  2. PinMode Alternate
    LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_0, LL_GPIO_MODE_ALTERNATE);

  3. Pulldown/Frequency
    LL_GPIO_SetPinPull(GPIOA, LL_GPIO_PIN_0, LL_GPIO_PULL_DOWN);
    LL_GPIO_SetPinSpeed(GPIOA, LL_GPIO_PIN_0, LL_GPIO_SPEED_FREQ_HIGH);

 

 

 

General Purpose Timers

  • 16bit autoreload, programmable prescaler

  • input capture (measure puls length of input signals)

  • output compare (generate Waveforms and PWM)

  • 4 independant channels (IC,OC,PWM,Onepulse-Mode output)

  • Sync circuits for ext. signals

  • Interrupt on

    • Update: over-/underflow, counter init

    • Trigger event (start/stop, init, count int/ext trigger)

    • IC/OC

  • incremental encoder

  •  Prescaler (16Bit)

Counter Modes

  1. Upcounting

  2. Downcounting mode

  3. Center-aligned mode (up/down counting)

  4. Master – Slave

 

Master-Slave Beispiel

Timer1 soll von Timer5 hochgezählt werden. Timer5 läuft im Sekundentakt über und löst für Timer1 ein Triggerereignis aus.

Image3

Trigger Event Selection

  • update event … reset, compare match

  • OC output compare  … compare match

Image4

Nicht jeder Timer kann Timer1 triggern:

Image5