Debugging mm32f3277 from zhufei, transplanted with micro Python development board

Zhuo Qing 2021-11-25 11:18:55
debugging mm32f3277 mm zhufei transplanted

Jane Medium : For those sent from flight by flight MicroPython Preliminary testing of the development board , Based on REPL An environment for interactive development .

key word MicroPython,MM32,Thonny

 

§01 open Send board information


today God (2021-10-27) Received the transplant sent by zhufei company, including MicroPython Development board .

One 、 essential information

1、 Circuit board

See the cover picture and the following picture for the front and back of the development board .

▲ chart 1.1.1 Back of circuit board

▲ chart 1.1.1 Back of circuit board

2、 The sample program

(1) Download address

(2) Sample program files

  • CCD.py
  • ENCODER.py
  • GPIO.py
  • LCD180.py
  • main.py
  • MicroPython Driver layer interface definition .xlsx
  • PWM.py
  • SERVO.py
  • TIMER.py
  • UART.py
  • ADC.py

3、MicroPython Driver layer interface definition

All modules in this version are summarized in seekfree Under module , It needs to be done first import seekfree Can pass seekfree. Method call , Or use from seekfree import . And this version is not released as the final version The final version will be launched in consultation with the smart party The final interface name and form may not be compatible with this version .

This demo firmware only realizes reading SD In the card main.py File execution function , Automatic or code opening of other files is not supported at the moment . This demo firmware is not the same as the final support firmware interface , Just to demonstrate functional integrity and enforceability . This demo firmware has many limitations , Limited by time, please check the attached demo routine , Each module can be through .help() View notes .

It can be downloaded through the serial port of the core board download interface REPL debugging , When using the loop, be sure to set the exit condition , Otherwise, the new... Cannot be executed Python sentence , The MCU needs to be restarted . When using the steering gear, be sure to use the power supply T Head power supply , Red positive pole , Black anode , Recommended supply voltage 8V. The available interface is the steering gear interface 、ADC、 Motor Interface PWM、 Encoder interface 、CCD Interface 、 The screen TFT1.8、 Lower right of motherboard ( There are signs to identify ) A serial port 、 Buttons, etc. .

▲ chart 1.1.2 Chip peripheral module interface

▲ chart 1.1.2 Chip peripheral module interface

Two 、 Power on test

1、 The power interface

A section of the floor has a power access lead , Can impose 2C,3C The lithium battery . The switch can control the power on and off . Next to the switch SPX2940 5V regulated power supply . SPX2940 Is the low differential pressure (0.28V@1A Output current ) regulated power supply .

stay SPX2940 There is a Schottky diode in front to prevent reverse connection .

Power part :
Access voltage :7V
SPX2940 Input :6.68V
SPX2940 Output :5.025V

▲ chart 1.2.1 Introduce the power supply into the power cord

▲ chart 1.2.1 Introduce the power supply into the power cord

Measure the input voltage and voltage SPX2940 Output voltage curve , As shown in the figure below . You can see if the input voltage exceeds 5.4V, The circuit can work normally .

▲ chart 1.2.2 Input voltage and SPX2940 Output voltage

▲ chart 1.2.2 Input voltage and SPX2940 Output voltage

from headm import *
from tsmodule.tsvisa import *
from tsmodule.tsstm32 import *
inv = linspace(0, 7, 50)
outv = []
for v in inv:
dh1766volt(v)
time.sleep(1.5)
meter = meterval()
outv.append(meter[1])
printff(v, meter[1])
tspsave('power', inv=inv, outv=outv)
plt.plot(inv, outv)
plt.xlabel("Input(V)")
plt.ylabel("Output(V)")
plt.grid(True)
plt.tight_layout()
plt.show()

2、 measurement TX Output

Download program port on the measuring circuit board TX Output waveform after power on . The message should be MicroPython REPL Output signal after power on .

▲ chart 1.2.3 Measure the... On the download board TX Output waveform

▲ chart 1.2.3 Measure the... On the download board TX Output waveform

You can see in the TX Output pulse waveform after power on .

▲ chart 1.2.4 measurement TX Output waveform after power on

▲ chart 1.2.4 measurement TX Output waveform after power on

Expand the output waveform, and you can generally see that the baud rate of the output waveform is 115200.

▲ chart 1.2.5 Expand the output waveform, and you can generally see that the baud rate of the output waveform is 115200

▲ chart 1.2.5 Expand the output waveform, and you can generally see that the baud rate of the output waveform is 115200

3、 Make Thonny Debug interface

stay ESP32-S Design and implementation of module adapter board Defined ESP32 Debug interface definition . You can see the corresponding GND-RXD0,TXD0 The order of and MM32 Debug interface TXD,RXD In reverse order . Need to go through an adapter , Yes TXD-RXD Alternate .

▲ chart 1.2.6 ESP32 Debug interface definition

▲ chart 1.2.6 ESP32 Debug interface definition

The following is made by ESP32 Debug the interface channel MM32 Core board 3PIN Connecting line . It will RX-TX Swap .

▲ chart 1.2.7 Make special debugging interface

▲ chart 1.2.7 Make special debugging interface

4、Thonny debugging

Set up Thonny in Option Of Interpreter Options , Set to CH340 Corresponding debugging interface .

▲ chart 1.2.8 Thonny Of Option Medium Interpreter Option settings for

▲ chart 1.2.8 Thonny Of Option Medium Interpreter Option settings for

After power on , You can see Thonny Received MM32 The message sent .

Found and execute /sd/main.py!
Set callback function success.

▲ chart 1.2.9 Thonny Debugging interface

▲ chart 1.2.9 Thonny Debugging interface

But directly Thonny Internal input command ,MM32 No response .

Directly check the waveform of the serial port debugging interface through the oscilloscope , You can see that its output amplitude is only 2V about . It is very different from the normal serial communication amplitude .

▲ chart 1.2.10 Programming interface (API) RX wave form

▲ chart 1.2.10 Programming interface (API) RX wave form

resolvent : stay MM32 Used on the development board 1k Ohmic connection RX to 3.3V.

▲ chart 1.2.11 stay RX,3.3V Welding between 1kΩ Pull up resistance

▲ chart 1.2.11 stay RX,3.3V Welding between 1kΩ Pull up resistance

After welding the pull-up resistor , You can see in the Thonny After entering enter , Sent RX The signal has become normal .

▲ chart 1.2.12 Improved RX wave form

▲ chart 1.2.12 Improved RX wave form

But still MM32 No, REPL Respond .

Existing problems :MM32 No one can REPL Respond to .

5、 Remove SD The program in the card

according to TX Information returned , See that the motherboard after power on should be executed SD In the card main.py Program . This procedure needs to be removed , Give Way MicroPython Back to REPL state .

▲ chart 1.2.13 Use SD Card reader / writer removal SD The program in the card

▲ chart 1.2.13 Use SD Card reader / writer removal SD The program in the card

(1)SD The files in the card

You can see SD The files in the card .

▲ chart 1.2.14 SD The files in the card

▲ chart 1.2.14 SD The files in the card

(2) Description document content

MM32F3270 Series MCU MicroPython Firmware instructions

1、 This demo firmware only realizes reading SD In the card main.py File execution function , Automatic or code opening of other files is not supported at the moment ;

2、 This demo firmware is not the same as the final support firmware interface , Just to demonstrate functional integrity and enforceability ;

3、 This demo firmware has many limitations , Limited by time, please check the attached demo routine , Each module can be through .help() View notes

4、 It can be downloaded through the serial port of the core board download interface REPL debugging , When using the loop, be sure to set the exit condition , Otherwise, the new... Cannot be executed Python sentence , The MCU needs to be restarted

5、 When using the steering gear, be sure to use the power supply T Head power supply , Red positive pole , Black anode , Recommended supply voltage 8V

6、 The available interface is the steering gear interface 、ADC、 Motor Interface PWM、 Encoder interface 、CCD Interface 、 The screen TFT1.8、 Lower right of motherboard ( There are signs to identify ) A serial port 、 Buttons, etc.

(3) remove SD After the card

take SD Card removal , Or put one of them main.py After deleting , Power on again .Thonny The platform has the following problems :

▲ chart 1.2.15 Connect Thonny The problems that followed

▲ chart 1.2.15 Connect Thonny The problems that followed

utilize STM32BL open COM8 debug , You can see that after power on ,MM32 MicroPython give :

▲ chart 1.2.16 STM32BL Received MM32 Messages sent

▲ chart 1.2.16 STM32BL Received MM32 Messages sent

※ error : I can't be sure ,MM32 current MicroPython Whether it can support REPL!

3、 ... and 、 Problem solving

1、 Use STM32 Interact

Rewrite STM32BL , Make it ECHO Set to :Return Under the circumstances , Can send CTRL+B Information , In this way, you can MicroPython Return to... In paste status REPL Interactive mode .

▲ chart 1.3.1 It can realize simple interactive development

▲ chart 1.3.1 It can realize simple interactive development

The above interactive development mode is still unavailable Thonny Environment to complete interactive program development .

 

§02 STM32 Interactive interface


root According to the previous test , You can see the use of Thonny Direct connection There will be errors on the development board , The following is written by myself STM32 Program , So that it can pass REPL Interface complete MicroPython Software download .

One 、STM32 Bootloader reform

1、 increase UDP command

stay STM32 add UDP command :MPDLD, It can pass the program in the shear board MicroPython Of REPL Download the command to the development board .REPL For paste software, see The MicroPython Interactive Interpreter Mode (aka REPL) .

By input CTRL-E(0x5), bring REPL Enter paste mode , Then send the program ASCII Content . adopt CTRL-D(0x4) Exit and execute .

if(strncmp(szString, "MPDLD", 5) == 0) {
 // MicroPython Dlownload
char szString[0x8000];
ClearInfor();
strcpy(szString, "");
Clipboard()->GetTextBuf(szString, sizeof(szString) - 1);
MessageBeep(0);
SendChar(0x5, PORT1); // Send CTRL+A
int nLength = strlen(szString);
int i;
for(i = 0; i < nLength; i ++)
SendChar(szString[i], PORT1);
SendChar(0x4, PORT1); // Send CTRL+B
return;
}

2、 Set up RETURN

▲ chart 2.1.1 Set up RETURN, bring STM32 The information box becomes an interactive window

▲ chart 2.1.1 Set up RETURN, bring STM32 The information box becomes an interactive window

Two 、 reform runpython_shift

about TEASOFT The sub main program of the software runpython_shift.py Add about STM32 Downloaded detection .

title = tspgetwindowtitle()
for t in title:
if t.find('Thonny') == 0:
ThonnyExec()
exit()
if t.find('Ô¶³Ì×ÀÃæ') >= 0:
ThonnyExec(1)
exit()
if t.find("STM32 BOOTLOADER") >= 0:
tspcopyclipboard()
pastestr = clipboard.paste().replace('\r', '')
clipboard.copy(pastestr)
stm32cmd("MPDLD")
tspfocuswindow("TEASOFT:1")
exit()

Be careful , Need to download MicroPython In the process of , Will be one of the '\r’ All filtered out .

3、 ... and 、 Test tool chain

1、 Test code

a = 1
b = 2
print(a+b)
for _ in range(10):
print(a)

2、 Download execution results

▲ chart 2.3.1 Download execution results

▲ chart 2.3.1 Download execution results

 

measuring Try to summarize ※


Yes From the transformation of zhufei MM32 Development board , If you put it behind SD Chuck, pull it out , You can directly enter REPL Interactive development status .

Use the serial port on the development board , And STM32 Connected to a , Form program download , The interface of the result display .

It is a pity that , For now, use directly Thonny The software has not been able to MM32 MicroPython Conduct REPL Interactive development . The specific reason is not clear . A method to query faults , It is through UART T- Type channel pair Thonny Environment and REPL Intercept and compare the interactive information between modules , You can find the problem .

▲ chart 3.1 UART T- Type apparatus

▲ chart 3.1 UART T- Type apparatus


■ Links to related literature :

● Related chart Links :

版权声明
本文为[Zhuo Qing]所创,转载请带上原文链接,感谢
https://pythonmana.com/2021/11/20211109010513923w.html

  1. Python basic syntax -- Boolean operation, break, continue, pass
  2. Python basic syntax -- loop
  3. Python first experience - efficient office, data analysis, crawler
  4. Modulenotfounderror: no module named 'Django summernote details
  5. Key points for Django to make personal blog website
  6. Path setting of templates in Django settings
  7. Leetcode 1611. Minimum one bit operations to make integers Zero (Python)
  8. Directory C: \ users \ a \ desktop \ Django_ The blog master is registered as the GIT root, but no git repository details are found there
  9. Django. Core. Exceptions. Improveconfigured: application labels aren't unique, duplicates: admin
  10. How to verify that Django has created the project details correctly
  11. How to create a database when using Django to construct a website
  12. The solution of using Django framework to create project in Windows system
  13. Running Python virtual environment on win10 system to execute ll_ Env \ scripts \ activate: unable to load file elaboration scheme
  14. Detailed explanation of constructing virtual environment with Django in Python 3
  15. Python implementation of affine cipher
  16. RC4 Python implementation
  17. Simple: Python_ Automatic body temperature clock
  18. 用python把两个csv中的日期的列提出年,做出新的一列,再把两个csv表格按照新做出的日期这列和ID号合并为一个表。
  19. python中类实例化后,其对象无法被其他模块调用方法
  20. [JSON] - Python creates JSON file format
  21. Utilisez Python pour proposer l'année de la colonne de date dans les deux CSV, faire une nouvelle colonne, puis combiner les deux tableaux CSV en un seul tableau avec la colonne de date et le numéro d'identification.
  22. 关于#python#的问题,请各位专家解答!
  23. ***
  24. ***
  25. 關於#python#的問題,請各比特專家解答!
  26. S'il vous plaît répondre aux questions de Python!
  27. About the import of Python class
  28. Magic Python property decorator: 1 line of code makes Python methods become properties in seconds
  29. Python 音频调整音量(附代码) | Python工具
  30. Python programming ideas [series of articles]
  31. Python crawler programming idea (67): modify nodes using pyquery
  32. Python crawler programming idea (66): using pyquery to obtain node information
  33. Python crawler programming idea (65): find nodes using pyquery
  34. Python crawler programming idea (64): using CSS selectors in pyquery
  35. Python crawler programming idea (63): basic knowledge of pyquery
  36. Python crawler programming idea (62): project practice: capturing cool dog online red song list
  37. Python crawler programming idea (61): project practice: capturing rental information
  38. Python crawler programming idea (60): get CSS selector code through browser
  39. Python爬虫编程思想(85):在Python中使用非关系型数据库
  40. Volume de réglage audio Python (avec Code) | outils Python
  41. Python crawler programming idea (59): get attribute value and text with beautiful soup CSS selector
  42. Python crawler programming idea (58): nested selection nodes with beautiful soup CSS selectors
  43. Python crawler programming idea (57): basic usage of CSS selector in beautiful soup
  44. Python crawler programming idea (56): find method of beautiful soup method selector
  45. Python crawler programming idea (55): find of beautiful soup method selector_ All method
  46. Python crawler programming idea (54): use beautiful soup to select sibling nodes
  47. Python crawler programming idea (53): use beautiful soup to select the parent node
  48. Django3.0 solves the problem of error reporting in reverse parsing
  49. Precautions for Python crawler
  50. Python 3 crawler series (1) -- climbing blind date websites
  51. Python到底是什么?为什么要学Python?
  52. #yyds干货盘点#Pandas数据清洗实用指南
  53. Python打包exe文件无法运行
  54. Two common ways to save files in Python
  55. #yyds幹貨盤點#Pandas數據清洗實用指南
  56. Yyds Dry Inventory pandas Data Cleaning Practical Guide
  57. PYTHON用LSTM长短期记忆神经网络的参数优化方法预测时间序列洗发水销售数据
  58. Python集成学习:自己编写构建AdaBoost分类模型可视化决策边界及sklearn包调用比较
  59. Python 3 makes a search software
  60. Python 3 simulated microblog login