Okay, here is the abstract and summary for the provided transcript, following the requested format.
Abstract:
This tutorial demonstrates using STM32 C0 series microcontroller peripherals, specifically Timers (TIM1, TIM16, TIM3) and Direct Memory Access (DMA), to generate a Pulse Width Modulated (PWM) signal and subsequently measure its frequency and duty cycle without requiring CPU core intervention. The process is broken down into three steps: first, generating a basic PWM signal on an onboard LED using TIM1 configured via STM32CubeMX/IDE with Low-Level (LL) libraries. Second, dynamically modifying the PWM duty cycle using TIM16 as a trigger source for DMA transfers that update TIM1's compare register. Third, measuring the generated PWM signal's period and pulse width using TIM3 in combined reset/trigger input capture mode, with two DMA channels automatically storing the captured rising and falling edge timings into memory variables. The tutorial highlights the use of hardware peripherals to offload timing-critical tasks from the CPU.
STM32 Timer & DMA Tutorial: PWM Generation and Measurement
0:00:04 Introduction: The video aims to show how to generate PWM using STM32 C0 timers and measure its frequency/duty cycle using timers and DMA, minimizing CPU core impact. It outlines a three-step process.
0:00:43 Project Setup: A new project is created in STM32CubeMX/IDE for an STM32C011C6 microcontroller (specifically on a Nucleo board).
0:01:37 Step 1 - PWM Generation Setup: Timer 1 (TIM1) is configured to generate PWM on Channel 1, using the internal clock source. This channel controls an onboard LED.
0:02:09 Pin Reassignment: The TIM1 Channel 1 output pin is reassigned to the correct physical pin connected to the LED on the Nucleo board (PA8).
0:02:41 Library Selection: Low-Level (LL) drivers are chosen over HAL for peripheral configuration to provide finer control.
0:03:04 Clock Configuration: The system clock is set to the maximum 48 MHz using the internal HSI48 oscillator.
0:05:05 Timer 1 Configuration (1 Hz PWM): TIM1 prescaler is set to 4799 and the counter period (ARR) to 9999 to achieve a 1 Hz frequency with the 48 MHz clock (48,000,000 / (4799+1) / (9999+1) = 1 Hz). The pulse value (CCR1) is set to 5000 for a 50% duty cycle. Code is generated and downloaded; the LED flashes slowly.
0:07:05 Step 2 - Dynamic Duty Cycle Intro: The plan is to increase TIM1's frequency and use Timer 16 (TIM16) with DMA to periodically change TIM1's duty cycle, altering the LED brightness.
0:07:28 TIM16 & DMA Setup: TIM16 is activated. A DMA request is configured for the TIM16 Update event, set to transfer data from Memory to Peripheral (TIM1's CCR1 register), using Word size and Circular mode.
0:08:56 TIM1 Configuration Update (1 kHz): TIM1's frequency is changed to 1 kHz (e.g., Prescaler 47, Period 999 gives 48MHz / 48 / 1000 = 1 kHz). The initial pulse (duty cycle) is set to 0.
0:09:34 TIM16 Configuration (2 Hz Update): TIM16 is configured for a 2 Hz frequency (Prescaler 4799, Period 4999 gives 48MHz / 4800 / 5000 = 2 Hz) to trigger the DMA transfer twice per second.
0:10:12 Code Implementation (Step 2): An array holding different duty cycle values is defined in the code. Initialization code for TIM1, TIM16, and the associated DMA channel is added. This setup allows TIM16's timing to automatically trigger DMA to load new duty cycle values from the array into TIM1's CCR1 register.
0:12:12 Step 3 - Measurement Intro: The goal is to use Timer 3 (TIM3) with DMA to measure the period and duty cycle of the PWM signal generated by TIM1.
0:12:52 TIM3 Configuration (Input Capture): TIM3 is enabled in 'Combined Reset Trigger Mode'. The trigger source is set to Input 1 (TI1FP1). Channel 1 is set to Input Capture Direct mode, and Channel 2 to Input Capture Indirect mode (capturing the same input signal but potentially on a different edge).
0:13:29 DMA Setup for TIM3: Two DMA channels are configured for TIM3: one for Channel 1 Capture/Compare event and one for Channel 2 Capture/Compare event. Both are set for Peripheral-to-Memory transfer, Half-Word size, and Circular mode.
0:14:16 TIM3 Timing Configuration: TIM3's prescaler is set to 47, making it count at 1 MHz (48MHz / (47+1)). The auto-reload register (ARR) is set to the maximum (65535).
0:14:41 Input Capture Polarity: TIM3 Channel 1 (Direct) is set to capture the Rising edge. TIM3 Channel 2 (Indirect) is set to capture the Falling edge of the same input signal (TIM3_CH1, pin PA6). Key Takeaway: This setup uses the rising edge to reset the timer and capture the period (in CCR1 via DMA), and the falling edge to capture the pulse width (in CCR2 via DMA).
0:15:35 Hardware Modification: A physical jumper wire is required on the Nucleo board (Connector CN10, pins 11 to 13) to connect the TIM1 PWM output (PA8) to the TIM3 Capture input (PA6).
0:15:57 Code Implementation (Step 3): Variables are defined to store the captured period and pulse width values from DMA. Initialization code is added to start TIM3 and its associated DMA channels.
0:17:30 Debugging: The code is built and downloaded, and a debug session is started to observe the variables being updated by DMA with the measured pulse width and period values (in microseconds, due to the 1 MHz TIM3 clock).