简 介: 对于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. INADDR_ANY的理解
  2. 判断点在直线的哪一侧_点与线、线与线、距离这些一锅煮,你能否顺利消化
  3. C语言 串口通知消息,编程模式·观察者模式、事件通知、消息队列三者区别
  4. java 不取空值_Java:如何更优雅的处理空值?
  5. 照着官网来安装openstack pike之neutron安装
  6. 南开大学20春计算机应用基础,南开大学-2020春学期《计算机应用基础》在线作业.txt.pdf...
  7. oracle 外连接内连接,oracle多表查询之内连接,外连接语句总结
  8. CentOS7 安装jdk8教程
  9. 计算机面试题100题,精选面试100题及答案.doc
  10. 远程控制软件老是断线怎么解决?
  11. RK3288开发板——Debian8系统制作
  12. 九度题目1341:艾薇儿的演唱会
  13. Ubuntu学习NO5.高效工作方式
  14. 孩子不听话家长怎么办
  15. python中 r'', b'', u'', f'' 的含义
  16. platfrom设备驱动框架
  17. 金九银十,一个新的王者在8月即将加冕——Treasure project(TPC)重磅来袭,你参与了吗?
  18. Mybatis源码基础解析
  19. DEJA_VU3D - Cesium功能集 之 004-动态单体化(整幢建筑)
  20. 微软键鼠外设八款齐发 创新蓝色LED光源

热门文章

  1. springboot之简洁集成mybatis
  2. SQL Server清空日志以及查看日志大小语句
  3. 记一次数据库查询语句的优化
  4. redis教程(一)之redis简介
  5. WEB前端性能优化小结
  6. 每天一个linux命令(48):watch命令
  7. 转帖 .Net(C#)纯GDI+绘制实时动态曲线图之二(曲线控件全部源码)
  8. emmc4.X boot1 and boot2
  9. Codeforces 859C - Pie Rules
  10. css样式之background详解(格子效果)