Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
MicroPython
MicroPython 多线程死机
发布于 2021-03-10 18:36:34 浏览:1478
订阅该版
```python import time from machine import Pin import rtthread import utime import _thread lock = _thread.allocate_lock() def pin_num(pin_index): """ Get the GPIO pin number through the GPIO index, format must be "P +
+ number", such as PE7 """ if pin_index[0] != 'P': print("ERROR : Please pass in the correct parameters P +
+ number, such as PE7") return if not pin_index[1].isupper(): print("ERROR : Please pass in the correct parameters P +
+ number, such as PE7") return return (ord(pin_index[1]) - ord('A')) * 16 + int(pin_index[2:]) led1 = Pin(("led_red", pin_num("PG2")), Pin.OUT_PP) led2 = Pin(("led_red", pin_num("PD3")), Pin.OUT_PP) led3 = Pin(("led_red", pin_num("PD4")), Pin.OUT_PP) led4 = Pin(("led_red", pin_num("PD5")), Pin.OUT_PP) def led1_thread(time_): led1_status = True while True: print("led1\r\n") led1.value(led1_status) led1_status = not(led1_status) utime.sleep(time_) def led2_thread(time_): led2_status = True while True: print("led2\r\n") led2.value(led2_status) led2_status = not(led2_status) utime.sleep(time_) def led3_thread(time_): led3_status = True while True: print("led3\r\n") led3.value(led3_status) led3_status = not(led3_status) utime.sleep(time_) def led4_thread(time_): led4_status = True while True: print("led4\r\n") led4.value(led4_status) led4_status = not(led4_status) utime.sleep(time_) _thread.start_new_thread(led1_thread, (1,)) _thread.start_new_thread(led2_thread, (2,)) _thread.start_new_thread(led3_thread, (3,)) _thread.start_new_thread(led4_thread, (4,)) # ``` 以上是在stm32f427测试RTThread-MicroPython多线程的脚本, 第一次运行脚本后,使用exit()退出。 第二次使用“python”命令再次进入后就没有任何反应了。 请问一下谁知道是什么原因呢?谢谢
查看更多
3
个回答
默认排序
按发布时间排序
苏鹏peng
2021-03-10
这家伙很懒,什么也没写!
不是系统死机了,是tshell没反应了,不知道啥原因。
cxhxy12345
2021-03-15
这家伙很懒,什么也没写!
你这个没有打印程序执行反馈的错误信息,我推测你是不是开启线程后,在退出时没有把线程清除,这样你就是同一个线程初始化二次了。
james_s
2021-03-26
这家伙很懒,什么也没写!
可以使用vscode调试一下看看正在运行到哪个函数了: https://www.rt-thread.org/document/site/tutorial/qemu-network/qemu_vscode/qemu_vscode/
撰写答案
登录
注册新账号
关注者
0
被浏览
1.5k
关于作者
苏鹏peng
这家伙很懒,什么也没写!
提问
1
回答
1
被采纳
0
关注TA
发私信
相关问题
1
请问rt-thread有没有移植micropython呢
2
micropython import 文件名的方式执行脚本问题
3
第一篇:Micropython 的起源和发展
4
第二篇:RT-Thread Micropython 简介
5
第三篇:RT-Thread Micropython 快速入门
6
第四篇:Micropython DIY 项目汇总
7
第五篇:Micropython 教程和资源
8
第六篇: RT-Thread MicroPython 学习经验和学习路线
9
RT-Thread MicroPython 最新开发板固件汇总【已失效】
10
有Mpy专门的板块啦~
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
机器人操作系统 (ROS2) 和 RT-Thread 通信
4
国产MCU移植系列教程汇总,欢迎查看!
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
VISION BOARD 第二弹 基础工程配置和点亮一个LED灯
2
musb移植问题记录【设备注册3次挂起】
3
关于使用CherryUSB时候使用外挂的usb phy 芯片配置的一点注意事项
4
【Vision Board 创客营】Vision Board上的ADC实践
5
FRDM-MCXN947 & RT-Thread的CAN实践——控制GM6020云台电机
热门标签
RT-Thread Studio
串口
LWIP
Env
SPI
Bootloader
AT
ART-Pi
Hardfault
CAN总线
FinSH
USB
文件系统
RT-Thread
DMA
SCons
线程
RT-Thread Nano
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
ota在线升级
WIZnet_W5500
I2C_IIC
UART
flash
cubemx
packages_软件包
freemodbus
潘多拉开发板_Pandora
PWM
定时器
ADC
BSP
中断
keil_MDK
编译报错
socket
MicroPython
GD32
msh
Debug
ulog
SDIO总线
SFUD
rt_mq_消息队列_msg_queue
C++_cpp
本月问答贡献
xiaorui
7
个答案
3
次被采纳
sakumisu
4
个答案
3
次被采纳
三世执戟
31
个答案
1
次被采纳
梦笑真美
18
个答案
1
次被采纳
踩姑娘的小蘑菇
14
个答案
1
次被采纳
本月文章贡献
Z_Y
2
篇文章
5
次点赞
Alipay
2
篇文章
3
次点赞
2345vor
2
篇文章
1
次点赞
比特饼干
1
篇文章
6
次点赞
Lu_盼盼
1
篇文章
3
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部