This project is focused on exploring the different timer modes of the STM32 microcontroller and how to simulate them using Proteus software.The project explores three different timer modes: One-Pulse, PWM Output, and Input Capture.
In the One-Pulse mode generates a single pulse when the timer reaches a specific value, and it is used for generating events such as triggering a sensor or actuator.
In the PWM Output mode generates a pulse-width modulated signal to control the duty cycle of an output signal, and it is used for controlling the brightness of an LED or the speed of a motor.
Finally, in the Input Capture mode measures the period and frequency of an input signal and is used for detecting the frequency of an input signal or measuring the speed of a motor.
Through this project, we will learn how to configure the STM32 timer modes for different applications. Additionally, we will discover how to simulate our designs using Proteus software, enabling us to test our circuits before implementing them in hardware.
Step One:- Open CubeMX & Create New Project Choose The Target MCU STM32F103C6 & Double-Click Its Name
- Go To The Clock Configuration & Set The System Clock To 60MHz
Configuration for the TIMER One-Pulse Mode:
- In the Categories tab, select the TIM3 then (enable Internal Clock & One Pulse Mode & PWM Generation Channel 3)
- In the Parameter settings tab, set the (Prescaler = 6000 & Counter Peroid = 10) The purpose of this settings is to generate a periodic time event with a 1ms interval which represents the length of the pulse.
- In the PWM Generaion Channel 3, set the (Mode = PWM mode 2 & Pulse 2=1)
- In the NVIC setting tab, Enable TIM3 global interrupt
Configuration for the TIMER PWM Output Mode:
- In the Categories tab, select the TIM2 then (enable Internal Clock & PWM Generation Channel 3 and 4)
- In the Parameter settings tab, set the (Prescaler = 60 & Counter Peroid = 100)
Configuration for the TIMER Input Capture Mode:
- In the Categories tab, select the TIM1 then (enable Internal Clock & Input Capture direct mode Channel 4)
- In the Parameter settings tab, set the (Prescaler =60 & Counter Peroid= 65535)
- In the Inpute Capture Channel 4 set Rising Edge
- In the NVIC setting tab, Enable TIM1 capture compare interrupt
- Generate The Initialization Code & Open The Project In CubeIDE
- Write The Application Layer Code
In file name :main.c
You can access the source code files via this link.
Step Two:- Open Proteus & Create New Project and click next
- Click on Pick Device
- Search for STM32F103C6 & SW-SPDT(switch) &LED_RED, ORANGE, YELLO
- Click on Virtual Instruments Mode then choose (VIRTUAL TERMINAL & OSCILLOSCOPE)
- Click on Terminal Mode then choose (DEFAULT & POWER &GROUND)
- finally make the circuit below and start the simulation
If you have any questions or suggestions don't hesitate to leave a comment below
Comments