Test the basic functions of the mm32f3277 micro Python development board flying one by one

Zhuo Qing 2021-11-25 11:18:25
test basic functions mm32f3277 mm

Jane Medium : For a given MicroPython The transplanted version has been preliminarily tested . In contrast ,MCU There are many modules in that are not yet supported . These tasks need to be completed as soon as possible in the near future .

key word MM32,MicroPython

 

§01 MicroPython Development


One 、 Background introduction

In order to be able to National Smart car competition for college students Based on MicroPython Development mode , It is suitable for students with non electronic background to participate in the exercise of smart car competition . In fact, in the previous game , be based on NXP Of OpenMV,OpenART All modules adopt MicroPython Development mode , However, these modules can not provide more ports to meet the development of smart car competition model works .

1、 Hardware modules

The following is based on smart MCU provided by zhufei technology MM32F3277 The development module of , Which has initially inhibited MicroPython Environment .

stay Debugging comes from flying by flying MM32F3277 Transplantation has MicroPython Development board This paper introduces the relevant information of the development board , And established through REPL Tool chain for interactive development .

▲ chart 1.1.1 Basic modules sent by flight

▲ chart 1.1.1 Basic modules sent by flight

2、 Development mode

utilize STM32 Bootloader Software composition MicroPython Of REPL Interactive interface , And can cut the MicroPython Download the program to MM32 Direct . At the same time, you can put REPL The output information is displayed .

Two 、 Development board hardware

1、 Operating instructions of experimental board

The following is the hardware operation instructions of the development version sent by zhufei Technology .

Test preparation :

Connect a normal motherboard , The Board sent has been connected to the screen and inserted SD card ;

▲ chart 1.2.1 Front of development board hardware

▲ chart 1.2.1 Front of development board hardware

Please use battery or regulated source to supply power from the power line , The voltage is recommended 8V( exceed 6V that will do ).
Or you can use black core board Type-C Power supply , But only use Type-C Do not connect the steering gear during power supply .

▲ chart 1.2.2 Behind the development version SD Card slot

▲ chart 1.2.2 Behind the development version SD Card slot

The back is SD Card socket , Connected to SD card , Power on the default operation card main.py, The phenomenon is on the black core board LED flashing .

Connection and environment settings :

▲ chart 1.2.3 Development board debugging port download interface

▲ chart 1.2.3 Development board debugging port download interface

The serial port connects the serial port of the download and debugging interface of the black core board , The baud rate is 115200, After the power is on, carry out... Through here RPEL Interaction , It should be noted that , If SD The card already has main.py Then priority will be given to main.py:

▲ chart 1.2.4 Serial terminal PuTTY Interface

▲ chart 1.2.4 Serial terminal PuTTY Interface

What is running at this time is SD Inside the card main.py file , We have attached SD The card should Python The program does not set exit , So you can't enter RPEL.

Need to put SD In the card main.py Delete or delete the file cyclically , Here we choose to delete the file , Reinsert the card and reset :

▲ chart 1.2.5 Get into REPL Debug status

▲ chart 1.2.5 Get into REPL Debug status

Now enter RPEL, And output MicroPython edition .

Try to do Python Statement execution :

Based on the attached example py file , You can try to run the display effect

▲ chart 1.2.6 function LCD180.help() After the results of the

▲ chart 1.2.6 function LCD180.help() After the results of the

Run the above statement , Corresponding to the electric quantity LCD The screen refreshes to full screen red and displays SEEKFREE word .

2、 Schematic diagram of experimental board

The principle can be downloaded from the following link : MM32F3277 Motherboard schematic diagram

(1) Core motherboard

▲ chart 1.2.7 Core motherboard pin definition

▲ chart 1.2.7 Core motherboard pin definition

(2) Backplane function definition

▲ chart 1.2.8 Backplane interface definition

▲ chart 1.2.8 Backplane interface definition

(3) Backplane sub circuit diagram

▲ chart 1.2.9 5V Power schematic diagram

▲ chart 1.2.9 5V Power schematic diagram

It's on the circuit board 3 individual 3.3V The power supply is provided with general power supply respectively 3.3V, camera , The power supply of the operational amplifier .
▲ chart 1.2.10 camera 3.3V Power Supply

▲ chart 1.2.10 camera 3.3V Power Supply

▲ chart 1.2.11 Steering gear power supply

▲ chart 1.2.11 Steering gear power supply

▲ chart 1.2.12 Definition of some interface pins

▲ chart 1.2.12 Definition of some interface pins

▲ chart 1.2.13 Definition of some interface pins

▲ chart 1.2.13 Definition of some interface pins

▲ chart 1.2.14 Definition of some interface pins

▲ chart 1.2.14 Definition of some interface pins

3、 ... and 、MicroPython function

The following is MM32F3277 Has been transplanted in MicroPython function . This paper makes a preliminary test of these functions .
▲ chart 1.3.1 Now it has been transplanted MicroPython Auxiliary function

▲ chart 1.3.1 Now it has been transplanted MicroPython Auxiliary function

 

§02 work Can test


One 、GPIO test

1、GPIO Output

(1) Test code

from seekfree import GPIO
pinpg1 = GPIO(0x67, 1, 1)
print("Test GPIO .")
while True:
pinpg1.low()
pinpg1.high()

(2) test result

Use an oscilloscope to measure MM32 Modular G7 Pin waveform .

▲ chart 2.1.1 Use an oscilloscope to measure MM32 Modular G7 Pin waveform

▲ chart 2.1.1 Use an oscilloscope to measure MM32 Modular G7 Pin waveform

▲ chart 2.1.2 G7 The waveform output by the port

▲ chart 2.1.2 G7 The waveform output by the port

Pass the above tests , You can see MicroPython The next cycle for port operation is about :22.28 μ s \mu s μs.

Because the above code is ultimately an endless loop , So you have to go through MM32 Reset can only be transferred from the dead circle .

(3) Modify debug port

In order to be able to control MM32 Reset , Add... To the original debugging port NRST Control line .

▲ chart 2.1.3 Modify debug port , increase RST Control port

▲ chart 2.1.3 Modify debug port , increase RST Control port

about STM32 Of MPDLD Added... To the command MM32 Reset process .

if(strncmp(szString, "MPDLD", 5) == 0) {
 // MicroPython Dlownload
char szString[0x8000];
strcpy(szString, "");
Clipboard()->GetTextBuf(szString, sizeof(szString) - 1);
ClearInfor();
ShowInfor("Reset MicroPython...");
RTSEnable(1, PORT1);
Sleep(100);
ClearPort(PORT1);
RTSEnable(0, PORT1);
ShowInfor("Wait for MicroPython comeback...");
double lfStart = GetDosTime();
int nGreatCount = 0;
int nGreatFlag = 0;
for(;;) {

if(GetDosTime() - lfStart > 2) break;
char c;
if(ReceChar(&c, PORT1) == 0) {

if(c == '>') nGreatCount ++;
if(c == ' ') {

if(nGreatCount >= 3) {

nGreatFlag = 1;
break;
}
}
}
}
int nLength = strlen(szString);
int i;
int nLine = 0;
for(i = 0; i < nLength; i ++) {

if(szString[i] == '\r') nLine ++;
}
char szTemp[512];
sprintf(szTemp, "Download MicroPython : %d lines/%d characters.", nLine, nLength);
ShowInfor(szTemp);
ShowInfor("Begin to download programm...");
Sleep(200);
if(nGreatFlag == 0) {

MessageBeep(0);
SendChar(0x2, PORT1); // Send CTRL+B
Sleep(100);
}
SendChar(0x5, PORT1); // Send CTRL+A
Sleep(100);
for(i = 0; i < nLength; i ++) {

ProgressBar1->Position = (i + 1) * 100 / nLength;
SendChar(szString[i], PORT1);
}
for(;;) {

char c;
if(ReceCharL(&c, PORT1, 20) > 0) break;
}
ShowInfor("-------------------------------------------------------------------------");
SendChar(0x4, PORT1); // Send CTRL+B
return;
}

After the modification , For circular programs , You can also easily download the program automatically .

(4) test toggle

from seekfree import GPIO
pinpg1 = GPIO(0x67, 1, 1)
print("Test GPIO .")
while True:
pinpg1.toggle()

▲ chart 2.1.4 toggle() The output waveform corresponding to the function

▲ chart 2.1.4 toggle() The output waveform corresponding to the function

From the above waveform , toggle( ) The running time is slightly longer than low(), high() Slow down .

2、LED

Now there is no... In the module time modular , This module can provide delay operation . therefore , The interval can only be realized through software delay .

Connect the wireless serial port HEADER Medium C6,C7,GND,+5V extraction , test GPIO Output control LED.

from seekfree import GPIO
led1 = GPIO(0x26, 1, 1)
led2 = GPIO(0x27, 1, 0)
print('Test LED.')
while True:
def delay(loop):
for _ in range(loop):
pass
led1.high()
led2.low()
delay(20000)
led1.low()
led2.high()
delay(20000)

▲ chart 2.1.5 LED Delay flashing

▲ chart 2.1.5 LED Delay flashing

3、 Test button

▲ chart 2.1.6 Keys and switches on the circuit board

▲ chart 2.1.6 Keys and switches on the circuit board

(1) Hardware

According to the previous hardware circuit diagram , Four keys are integrated on the circuit board :G0,G1,G2,G3. Their corresponding ports are :GPIOG0, G1,G2,G3.

▲ chart 2.1.7 Four buttons on the development board

▲ chart 2.1.7 Four buttons on the development board

(2) Testing software

from seekfree import GPIO
led1 = GPIO(0x26, 1, 1)
led2 = GPIO(0x27, 1, 0)
btn1 = GPIO(0x60, 0, 1)
btn2 = GPIO(0x61, 0, 1)
btn3 = GPIO(0x62, 0, 1)
btn4 = GPIO(0x63, 0, 1)
print('Test LED.')
def delay(loop=50000):
for _ in range(loop):
pass
while True:
print([btn1.value(), btn2.value(), btn3.value(), btn4.value()])
delay(50000)

4、 Test the dial switch

There are also two dial switches on the circuit board , Respectively corresponding D14,D15. adopt GPIO You can read their status . The test method is the same as the above buttons .

from seekfree import GPIO
print('Test LED.')
def delay(loop=50000):
for _ in range(loop):
pass
led1 = GPIO(0x26, 1, 1)
led2 = GPIO(0x27, 1, 0)
btn1 = GPIO(0x60, 0, 1)
btn2 = GPIO(0x61, 0, 1)
btn3 = GPIO(0x62, 0, 1)
btn4 = GPIO(0x63, 0, 1)
sw1 = GPIO(0x3e, 0, 1)
sw2 = GPIO(0x3f, 0, 1)
while True:
print([btn1.value(), btn2.value(), btn3.value(), btn4.value(), sw1.value(), sw2.value()])
delay(50000)

▲ chart 2.1.8 Measuring keys and dialing switches

▲ chart 2.1.8 Measuring keys and dialing switches

Two 、ADC test

1、ADC.help()

▲ chart 2.2.1 ADC.help() display information

▲ chart 2.2.1 ADC.help() display information

2、adc.value()

Lead the of the electromagnetic module interface to the bread board , Use a potentiometer to obtain different voltages , Send to A4.

▲ chart 2.2.2 Collect to 1024 individual ADC The number

▲ chart 2.2.2 Collect to 1024 individual ADC The number

Variance of data : 5.

because MicroPython Floating point operations are not supported . Therefore, we need to use the integer number to complete the relevant calculation .

from seekfree import ADC,GPIO
adc = ADC(0)
adc.channel_init(adc.A4)
print('Test ADC.')
def delay(loop=50000):
for _ in range(loop):
pass
def sqrt(x):
left = 0
right = x//2+1
while left < right:
middle = left + (right-left+1)//2
square = middle * middle
if square > x:
right = middle-1
else: left = middle
return left
SAMPLE_NUM = 1024
adcdim = [0]*SAMPLE_NUM
for i in range(SAMPLE_NUM):
adcdim[i] = adc.value(adc.A4)
print(adcdim)
count = 0
for s in adcdim:
count += s
average = count//SAMPLE_NUM
sigma = 0
for s in adcdim:
ss = s - average
sigma += ss**2
print(sqrt(sigma//SAMPLE_NUM))

3、 ... and 、PWM test

On the beta PWM Pass respectively A0,A1,A2,A3 Output .

1、 Basic test

from seekfree import PWM,GPIO
pwm = PWM(16000)
pwm.channel_init(pwm.A0, 5000)
print("Test PWM")
  • duty = 5000
    ▲ chart 2.3.1 A0 Output PWM wave form
    ▲ chart 2.3.1 A0 Output PWM wave form
  • duty = 500

▲ chart 2.3.2 A0 Output PWM wave form

▲ chart 2.3.2 A0 Output PWM wave form

2、 utilize ADC change PWM

from seekfree import PWM,GPIO,ADC
pwm = PWM(16000)
pwm.channel_init(pwm.A0, 500)
adc = ADC(0)
adc.channel_init(adc.A4)
def delay(loop=50000):
for _ in range(loop):
pass
print('Test PWM...')
while True:
adcvalue = adc.value(adc.A4)
pwmvalue = adcvalue*10000//0x1000
print(adcvalue, pwmvalue)
pwm.duty(pwm.A0, pwmvalue)
delay(10000)

▲ chart 2.3.3 Shaking PWM

▲ chart 2.3.3 Shaking PWM

Through the collection of ADC After averaging , Under control PWM, The waveform is very stable .

from seekfree import PWM,GPIO,ADC
pwm = PWM(16000)
pwm.channel_init(pwm.A0, 5000)
adc = ADC(0)
adc.channel_init(adc.A4)
def delay(loop=50000):
for _ in range(loop):
pass
print('Test PWM...')
while True:
sigma = 0
for i in range(256):
sigma += adc.value(adc.A4)
adcvalue = sigma//256
pwmvalue = adcvalue*10000//0x1000
pwm.duty(pwm.A0, pwmvalue)
delay(1000)

▲ chart 2.3.4 adopt ADC change PWM Duty cycle

▲ chart 2.3.4 adopt ADC change PWM Duty cycle

Four 、Timer test

1、 Basic test

Set the timer's callback function .

from seekfree import TIMER,GPIO
led1 = GPIO(0x26, 1, 1)
led2 = GPIO(0x27, 1, 0)
def timer_callback(s):
led1.toggle()
print(s.count())
tim = TIMER(200)
tim.callback(timer_callback)
while True:
pass

 

measuring Try to summarize ※


Yes On MM32 Of MicroPython The transplanted version has been preliminarily tested . You can also see that the migration of this version still needs some enrichment .

  • Lack of SPI, I2C,CAN Bus support .
  • Lack of support for floating point operations ;
  • Lack of SD Card file access support ;

The above functions need to be further improved through later supplement .


■ Links to related literature :

● Related chart Links :

版权声明
本文为[Zhuo Qing]所创,转载请带上原文链接,感谢
https://pythonmana.com/2021/11/20211109010513920W.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