当前位置: 首页 > ds >正文

【AT32】AT32定时器

at32的定时器

使用work Bench 启动一个基本的定时器 6 使用
在这里插入图片描述生成的代码如下

void wk_tmr6_init(void)
{/* add user code begin tmr6_init 0 *//* add user code end tmr6_init 0 *//* add user code begin tmr6_init 1 *//* add user code end tmr6_init 1 *//* configure counter settings */tmr_cnt_dir_set(TMR6, TMR_COUNT_UP);tmr_period_buffer_enable(TMR6, FALSE);tmr_base_init(TMR6, 999, 95);/* configure primary mode settings */tmr_primary_mode_select(TMR6, TMR_PRIMARY_SEL_OVERFLOW);/* configure overflow event */tmr_overflow_request_source_set(TMR6, TRUE);tmr_counter_enable(TMR6, TRUE);/*** Users need to configure TMR6 interrupt functions according to the actual application.* 1. Call the below function to enable the corresponding TMR6 interrupt.*     --tmr_interrupt_enable(...)* 2. Add the user's interrupt handler code into the below function in the at32f425_int.c file.*     --void TMR6_GLOBAL_IRQHandler(void)*//* add user code begin tmr6_init 2 *//* add user code end tmr6_init 2 */
}

启动 此定时器调用注释的

--tmr_interrupt_enable(...)
tmr_interrupt_enable(TMR6, TMR_OVF_INT, TRUE); //启动定时器

然后在定时器回调函数里面调用用户函数

void TMR6_GLOBAL_IRQHandler(void)
{/* add user code begin TMR6_GLOBAL_IRQ 0 *//* add user code end TMR6_GLOBAL_IRQ 0 *//* add user code begin TMR6_GLOBAL_IRQ 1 *//* add user code end TMR6_GLOBAL_IRQ 1 */
}

注意要在 回调 添加 清除 中断标志位 否则会一直卡在 定时器当中

if (tmr_flag_get(TMR6, TMR_OVF_FLAG) != RESET) {
tmr_flag_clear(TMR6, TMR_OVF_FLAG);}
http://www.xdnf.cn/news/14159.html

相关文章:

  • 【华为Pura 80 Ultra影像真的有点东西】
  • 批处理实现:自动抓取perfetto日志 自动导出到当前文件夹 自动打开分析页面
  • NLP学习路线图(四十四):跨语言NLP
  • 【Linux基础知识系列】第二十四篇-网络配置文件的解析与修改
  • error: error:0308010c:digital envelope routines::unsupported
  • 联想笔记本怎么装win11专业版_联想笔记本用u盘装win11专业版图文教程
  • 【BrowserTools MCP:让 AI 直接调试你的网页应用】
  • 深度学习笔记26-天气预测(Tensorflow)
  • 光伏功率预测 | RF随机森林多变量单步光伏功率预测(Matlab完整源码和数据)
  • react react-router-dom中获取自定义参数v6.4版本之后
  • 使用大模型预测甲状旁腺恶性肿瘤的研究报告
  • 2025年6月英语四级CET-4作文预测10篇7页PDF
  • 电路图识图基础知识-电动机的保护电路保护方式(二十六)
  • (题目向,随时更新)动态规划算法专题(2) --见识常见的尝试模型
  • centos 8.3(阿里云服务器)mariadb由系统自带版本(10.3)升级到10.6
  • AI与机器学习ML:利用Python 从零实现神经网络
  • 科技新底座揭幕!2025 MWC上海锚定AI+、5G融合、双区创新三大引擎
  • 扩展模块--QWebEngine功能及架构解析
  • XPath 注入与修复
  • 通过SMS凭据管理系统,实现数据库密码、服务器密码、Token等机密信息的临时授权和安全合规使用
  • 【unitrix】 1.5 Unitrix库结构和设计意图(lib.rs)
  • Linux系统技能:用户权限精细化管理与性能调优秘籍分享
  • 开疆智能ModbusTCP转Devicenet网关连接西门子200Smart与费托斯阀岛案例
  • Redis高级|Redis单线程VS多线程(基础)
  • 【DNS解析】DNS解析从入门到精通
  • 前端持续集成和持续部署简介
  • 英飞凌亮相SEMICON China 2025:以SiC、GaN技术引领低碳化与数字化未来
  • 圆与 π | 从几何之美到数学与物理的奇妙之旅
  • 2025【证券从业】数值事件
  • 系统架构设计师 1