7545 views|28 replies

1w

Posts

25

Resources
The OP
 

Another way to use MicroPython serial port receive interrupt [Copy link]

 
 

MicroPython currently only officially provides the serial port receive interrupt function in Wipy. Although it can be used in other hardware ported versions, there are many problems, and sometimes it is not stable, and some strange problems may occur, causing it to fail to run normally.

UART.irq(trigger, priority=1, handler=None, wake=machine.IDLE)

At present, in addition to waiting for the official release of new firmware that supports serial port interrupt function, we can also use the following method to implement serial port interrupt:

  • Set the serial port's RXD pin to input
  • Define the level change interrupt of the RXD pin and activate the timer in the callback function
  • To set a timer, you can use machine.Timer (software timer)
  • Set the timer callback function and process the serial port receiving function in the callback function
  • Initialize the serial port

Furthermore, if a timer can be added for serial port reception protection, the timer and serial port can be turned off after no new data is received for a certain period of time to save power consumption; or a group of data reception is considered complete and the MCU is notified for processing.

The above method is tested normally on pyboard. If all functions are encapsulated into a class, it will be more convenient to use.

Latest reply

see   Details Published on 2024-9-24 14:40
 
 

1w

Posts

25

Resources
2
 

Reference Program

The following test uses serial port 1

游客,如果您要查看本帖隐藏内容请回复

 
 
 

3386

Posts

0

Resources
3
 

Learned

 
 
 

4

Posts

0

Resources
4
 

Study hard and make progress every day

 
 
 

2

Posts

0

Resources
5
 
I still replied to see the answer
 
 
 

6

Posts

0

Resources
6
 

Beginners look

 
 
 

1

Posts

0

Resources
7
 

Study

 
 
 

21

Posts

0

Resources
8
 

Learn to be more powerful

 
 
 

1

Posts

0

Resources
9
 

Study

 
 
 

2

Posts

0

Resources
10
 

Study it, it helps

 
 
 

1

Posts

0

Resources
11
 

Learned

 
 
 

1

Posts

0

Resources
12
 
Okay, let's learn
 
 
 

3

Posts

0

Resources
13
 

Learned :)

 
 
 

1

Posts

0

Resources
14
 
haoyahaoya
 
 
 

1

Posts

0

Resources
15
 

bdbdbdbdb

 
 
 

3

Posts

0

Resources
16
 

Learn

 
 
 

2

Posts

0

Resources
17
 

Learned

 
 
 

3

Posts

0

Resources
18
 

Support domestic production

 
 
 

2

Posts

0

Resources
19
 

Learned

 
 
 

2

Posts

0

Resources
20
 

I need to learn, I am using UART

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list