You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
623 B
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 超声波测距 - 基本定时器方法
- 初始化外部晶振配置SYSCLK与Timer Clock均为72MHz
- 配置GPIO
- PA11配置为Output设置标签TRIG
- PA10配置为Input设置标签ECHO
- TIM1配置
- Clock Source配置为Internal Clock
- Prescaler配置为720-1即分频到周期10us
- Counter Period配置为最大值65535
- 将USART2配置为Asynchronous
- 测距流程
- 拉高TRIG等待5ms再拉低即触发模块输出
- 清零定时器的计数等待ECHO引脚拉高
- ECHO拉高时启动定时器
- 待ECHO拉低时停止定时器并计算距离