MicroprocessorHVT2019 Lec09 STM32 Timer
MicroprocessorHVT2019 Lec09 STM32 Timer
• Update events
– Counter overflow/underflow
– Counter initialized
– Others
• Trigger
– Counter start/stop
– Counter Initialize
– Others
CK_PSC
Prescaler Period
Quiz
• Nếu tần số xung clock bus APB1 nối với Timer là fCK_PSC = 96MHz
(Timer clock), hãy tính giá trị Prescaler và Period để Timer tạo ra
ngắt (UpdateEvent - UEV) mỗi 0.5s?
• Prescaler =
• Period =
• Đáp án:
• CK_PSC = 96.000.000 Hz
• Prescaler = 47999
• Period = 1999
Clock configuration: STM32F411
fCK_PSC
Clock configuration: STM32F103
Timer2 (TIM2) configuration
Interrupt
Setting
for TIM2
Start the TIM2 in Interrupt mode
Main loop
do nothing!
HAL_TIM_PeriodElapsedCallback
Kết quả đo kiểm tra tín hiệu PD14 có tần số 1Hz trên dao
động ký
Watch demo on YouTube
https://youtu.be/ER5pQJzaqf8
Thank You!
Video hướng dẫn thực hành
TIMER tại HOCARM.ORG
• https://dutudn-
my.sharepoint.com/:v:/g/personal/thanghv_d
ut_udn_vn/EYLV0EA2KItBrj00s-
xebT4BZZlcMiUBmnxDxW8tbI4Ysw?e=xlmSz
K