简 介: 对于SuYong发送过来的带有Timer功能版本的MicroPython进行了测试。在新版的MicroPython中,可以最多定义两个不同频率的定时器中断,完成对于周期时间的控制和输出。这一点在很多数字控制系统中应用比较重要。

关键词MM32TimerMicroPython

#mermaid-svg-J7mtihbjxox1oZvw {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-J7mtihbjxox1oZvw .error-icon{fill:#552222;}#mermaid-svg-J7mtihbjxox1oZvw .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-J7mtihbjxox1oZvw .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-J7mtihbjxox1oZvw .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-J7mtihbjxox1oZvw .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-J7mtihbjxox1oZvw .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-J7mtihbjxox1oZvw .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-J7mtihbjxox1oZvw .marker{fill:#333333;stroke:#333333;}#mermaid-svg-J7mtihbjxox1oZvw .marker.cross{stroke:#333333;}#mermaid-svg-J7mtihbjxox1oZvw svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-J7mtihbjxox1oZvw .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-J7mtihbjxox1oZvw .cluster-label text{fill:#333;}#mermaid-svg-J7mtihbjxox1oZvw .cluster-label span{color:#333;}#mermaid-svg-J7mtihbjxox1oZvw .label text,#mermaid-svg-J7mtihbjxox1oZvw span{fill:#333;color:#333;}#mermaid-svg-J7mtihbjxox1oZvw .node rect,#mermaid-svg-J7mtihbjxox1oZvw .node circle,#mermaid-svg-J7mtihbjxox1oZvw .node ellipse,#mermaid-svg-J7mtihbjxox1oZvw .node polygon,#mermaid-svg-J7mtihbjxox1oZvw .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-J7mtihbjxox1oZvw .node .label{text-align:center;}#mermaid-svg-J7mtihbjxox1oZvw .node.clickable{cursor:pointer;}#mermaid-svg-J7mtihbjxox1oZvw .arrowheadPath{fill:#333333;}#mermaid-svg-J7mtihbjxox1oZvw .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-J7mtihbjxox1oZvw .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-J7mtihbjxox1oZvw .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-J7mtihbjxox1oZvw .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-J7mtihbjxox1oZvw .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-J7mtihbjxox1oZvw .cluster text{fill:#333;}#mermaid-svg-J7mtihbjxox1oZvw .cluster span{color:#333;}#mermaid-svg-J7mtihbjxox1oZvw div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-J7mtihbjxox1oZvw :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}

MM32F3277 MicroPython
目 录
Contents
测试基本功能
测试代码
测试结果
两个Timer
Timer个数
测试两个Timer
测试结果
测试总结

§01 MM32F3277
   MicroPython


  今天收到 MindMotion SuYong发送过来的MM32F3277 带有Timer的MicroPython的版本。下面对于这个版本进行测试。

一、测试基本功能

1、测试代码

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# TEST1.PY                     -- by Dr. ZhuoQing 2021-11-29
#
# Note:
#============================================================
from machine                import Pin,Timer
import utime
led0 = Pin('PB2', mode=Pin.OUT_PUSHPULL)
print("Test Timer.")
def t0_callback(self):led0(1-led0())
t0 = Timer(0, mode=Timer.PERIODIC, callback=t0_callback, period=100)
while True:pass
#------------------------------------------------------------
#        END OF FILE : TEST1.PY
#============================================================

2、测试结果

>> Reset MicroPython...
>> Wait for MicroPython coming back...
>> Download MicroPython : 27 lines/657 characters.
>> -------------------------------------------------------------------------Test Timer.

二、两个Timer

1、Timer个数

  在现在的版本中,只有两个Timer可以用。

machine_timer_conf_t timer_conf[MACHINE_TIMER_NUM];const machine_timer_obj_t timer0 = {.base = {&machine_timer_type}, .timer_port = TIM6, .timer_irqn = TIM6_IRQn, .timer_id = 0u, .conf = &timer_conf[0]};
const machine_timer_obj_t timer1 = {.base = {&machine_timer_type}, .timer_port = TIM7, .timer_irqn = TIM7_IRQn, .timer_id = 1u, .conf = &timer_conf[1]};const machine_timer_obj_t * machine_timer_objs[] =
{&timer0 ,&timer1 ,
};

  在MM32F3277上共有八个TIM模块,其中两个给了Timer, 四个给了PWM,两个给Encoder。

2、测试两个Timer

from machine                import Pin,Timer
import utime
import mathled0 = Pin('PB2', mode=Pin.OUT_PUSHPULL)print("Test Timer.")def t0_callback(self):led0(1-led0())count = 1
def t1_callback(self):global countprint(math.sin(count*math.pi/100))count += 1t0 = Timer(0, mode=Timer.PERIODIC, callback=t0_callback, period=100)
t1 = Timer(1, mode=Timer.PERIODIC, callback=t1_callback, period=500)
while True:pass

3、测试结果

  可以看到两个不同频率间隔的Timer可以独自完成输出文字,闪烁LED等。

※ 测试总结 ※


  对于SuYong发送过来的带有Timer功能版本的MicroPython进行了测试。在新版的MicroPython中,可以最多定义两个不同频率的定时器中断,完成对于周期时间的控制和输出。这一点在很多数字控制系统中应用比较重要。


MM32F3277 MicroPython 的定时器功能相关推荐

  1. 测试MindMotion MM32F3277 MicroPython -2021-11-20新增PWM版本

    简 介: 对于初步实现的MicroPython的版本进行了测试.可以看到这个版本在MCU的硬件层面还存在BUG,在实际管脚上尚无法输出对应的PWM波形. 关键词: MM32,MicroPython,P ...

  2. 设计带有SD卡的 MM32F3277 MicroPython 实验板

    简 介: 本文测试了基于MM32F3277下的MicroPython电路板设计.其中包含有SD卡接口,常用外设接口等.验证了现在的移植的MicroPython的对文件的基本操作功能.通过测试发现现在的 ...

  3. python怎样编写定时程序_Python如何实现定时器功能

    Timer: 隔一定时间调用一个函数,如果想实现每隔一段时间就调用一个函数的话,就要在Timer调用的函数中,再次设置Timer.Timer是Thread的一个派生类 python中的线程提供了jav ...

  4. SysTick系统定时器(功能框图和优先级配置)

    SysTick系统定时器(功能框图和优先级配置) SysTick-系统定时器是属于 CM3 内核中的一个外设,内嵌在 NVIC 中.系统定时器是一个 24bit (2^24)的向下递减的计数器,计数器 ...

  5. C++最普通的定时器功能实现

    由于简单测试,就实现一个最简单的定时器功能 头文件: #pragma once #include <iostream> #include <string> #include & ...

  6. STM32F407核心板定时器功能引脚分配

    STM32F407 定时器功能引脚分配

  7. STM32定时器功能概括

    定时器分类 不同的芯片定时器的个数也是不同的,以STM32F103ZE有8个定时器(定时器的具体个数查相关手册). 定时器的分类:高级定时器.通用定时器.基本定时器,这3类定时器的功能各不相同. 定时 ...

  8. 浅谈一下单片机的定时器功能

    MCU相当于一个微控制器,与其他芯片相比,最大的特点是它的可编程特性.由于其可编程功能可以广泛应用于生活的各个方面,如手机.PC周边设备.遥控器.汽车.电子.智能家居等.但这些都是使用具有不同电路的M ...

  9. Arduino ESP32定时器功能使用

    Arduino ESP32定时器功能使用 ESP32硬件定时器介绍 ESP32 芯片包含两个硬件定时器组.每组有两个通用硬件定时器.它们都是基于 16 位预分频器和 64 位自动重载功能的向上/向下计 ...

最新文章

  1. 【iOS_Development】文件操作
  2. Android学习摘要一之Android历史
  3. MVC的传递数据的方法
  4. 多个高危 BIOS 缺陷影响英特尔处理器,特斯拉 Model 3 未幸免,可用于供应链攻击...
  5. shell编程规范与变量
  6. 退役前的做题记录3.0
  7. 计算机图形图像处理应用教程,计算机图形图像处理——Photoshop实用教程
  8. 2020-21《全球软件质量报告》解读
  9. sql升级重启计算机失败win10,win10系统电脑安装sql server需要一直重启的解决方法...
  10. “黑盒工坊”,轻松管理《魔兽世界》插件!
  11. 【Android Studio使用教程2】Android Studio创建项目
  12. 【数据可视化】Echarts世界地图需要的数据 - JSON格式世界国家中英文对照表
  13. 目标检测 (Detection) 算法综述
  14. Linux常用指令<三>
  15. 未知USB设备 端口重置失败
  16. Let‘s Go Rust 系列之定时器 Ticker Timer
  17. 卡尔曼滤波原理二:扩展卡尔曼
  18. oracle调优 oracle培训
  19. C语言题解:谁是凶手!
  20. 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛

热门文章

  1. spring (由Rod Johnson创建的一个开源框架)
  2. Spring----Spring Boot Rest的使用方法
  3. Codeforces 458A Golden System
  4. LYNC2013部署系列PART2:后端部署
  5. 3D 引擎 Unity 2019.1 正式发布,引入新的轻量级渲染管道
  6. Go开发之路 -- Go语言基本语法 - 作业
  7. 资深专家深度剖析Kubernetes API Server第1章(共3章)
  8. 发挥主观能动性,才可以能常人之所不能 - 阿里云MVP 杨洋专访
  9. 在 Java 中利用 redis 实现 LBS 服务
  10. Selenium2Lib库之鼠标事件常用关键字实战