Jane Medium : For as of (2021-11-08 21:13:44) From smart MicroPython stay MM32F3277 Test the consistent basic functions on . And give in addition MicroPython Of the relevant modules の Basic test call version .
key word
: MM32F3277,MicroPython
stay Production test MM32F3277-MicroPython Minimum circuit board Tested based on MM32F3277 Of MicroPython Test board . You can also see that its clock does not need . The following design is suitable for the test of bread board MicroPython Test board .
The following uses the module support category provided by smart Su Yong :
▲ chart 1.1.1 MM32F3277 Module in
▲ chart 1.1.2 MM32F3277 Seven UART Corresponding pins
▲ chart 1.2.1 Schematic diagram
▲ chart 1.2.2 Rapid plate making PCB The design
In the above design , For the analog power part (VDDA,VSSA) No one can supply power alone , This will affect ADC,DAC Signal performance . In the following version , take VDDA,VSSA Separate power supply .
AD\MM32\TestMM32\TestMM32MicroPythonPIN.SchDoc
▲ chart 1.2.3 take VDDA,VSSA use 0Ω Resistance for separate power supply
▲ chart 1.2.4 Designed single side rapid plate making PCB chart
The problem is :
In the above design , Remaining problems : It's just that there's no going to be VSSDA extraction , When an external signal is input , No signal bottom line .
Use One minute plate making method , Finish making the circuit board in five minutes , Welding and commissioning .
Welding test circuit board , As shown in the figure below :
▲ chart 1.3.1 Test circuit board after welding
exert +5V Working voltage . Inside the measuring plate 3.3V The power supply voltage meets the requirements .
Come down from Su Yong MicroPython. This version requires an external crystal .
▲ chart 1.3.2 Use MM32-LINK download MicroPython
▲ chart 1.3.3 download MicroPython Then the clock signal is measured on the crystal
MicroPython After writing , After power on, it will send MicroPython Version information for . Can be in TX1 The waveform is measured on the .
▲ chart 1.3.4 Measure after power on TX1 The waveform on the screen
Connect... On the beta REPL Interface (UART1) To the serial terminal of the computer , The version information can be read after the circuit board is powered on .
▲ chart 1.3.5 REPL Cue symbols
root According to Su Yong's feedback , Now this version MicroPython The following modules have been supported :Pin、ADC、UART、SDCard、utime. The use of modules follows MicroPython Official website The agreement given . Let's test the current version .
from machine import Pin,ADC,UART,freq
import machine
import utime
dir(machine)
dir(utime)
freq()
Reset MicroPython...
Wait for MicroPython comeback...
Download MicroPython : 9 lines/109 characters.
Begin to download programm...
-------------------------------------------------------------------------
['__name__', 'ADC', 'Pin', 'SDCard', 'UART', 'freq', 'mem16', 'mem32', 'mem8']
['__name__', 'sleep', 'sleep_ms', 'sleep_us', 'ticks_add', 'ticks_cpu', 'ticks_diff', 'ticks_ms', 'ticks_us']
96000000
>>>
You can see from above , Inside OSC The frequency of is 96MHz.
from machine import Pin,ADC,UART,freq
import utime
while True:
print('A')
utime.sleep_ms(100)
REPL Interface output ’A’, every other 100ms Output a number .
test GPIO I / O function of .
According to Su Yong's feedback :
from machine import Pin
pin0 = Pin('PB2', mode=Pin.OUT_PUSHPULL)
pin0(1)
pin0.low()
test GPIO Corresponding output function .
from machine import Pin,ADC,UART,freq
import utime
led = Pin('PB2', Pin.OUT_PUSHPULL)
while True:
led(1)
utime.sleep_ms(100)
led(0)
utime.sleep_ms(100)
▲ chart 2.3.1 flashing PB2 Corresponding LED
Pass the test twice IO Changes in high and low levels of , To test in MicroPython Next for IO The minimum operation time of the port .
from machine import Pin,ADC,UART,freq
import utime
led = Pin('PB2', Pin.OUT_PUSHPULL)
while True:
led(1)
led(0)
By measuring LED According to the change waveform of the port , Perform the initial GPIO The time required for operation is about :17 μ s \mu s μs.
▲ chart 2.3.2 adjacent GPIO High and low level operation
from machine import Pin
import utime
led = Pin('PB2', Pin.OUT_PUSHPULL)
btn = Pin('PB7', Pin.IN_PULLUP)
print("Test Pin input and output.")
while True:
if btn.value() > 0:
led.high()
else: led.low()
Use the DuPont line to PB7 Grounding , Can be observed LED(PB2) Extinguish .
▲ chart 2.3.3 take PB7 Grounding can be observed PB2(LED) Extinguish
▲ chart 2.3.4 test DAC The sample program
DAC0
:PA4
DAC1
:PA5
from machine import Pin,ADC,DAC
dac0 = DAC(0)
dac1 = DAC(1)
print('Test DAC ...')
dac0.write_u16(0x800)
dac1.write_u16(0x400)
Measure with a digital multimeter :
DAC0(PA4)
:1.649V
DAC1(PA5)
: 0.825V
from machine import Pin,ADC,DAC
from math import *
dac0 = DAC(0)
dac1 = DAC(1)
print('Test DAC ...')
angle = [int((sin(i * pi * 2 / 100)+1.0)/2*0x600+0x200) for i in range(100)]
print(angle)
while True:
for a in angle:
dac0.write_u16(a)
dac1.write_u16(0xa00 - a)
Use an oscilloscope to measure DAC0,DAC1 Waveform of .
▲ chart 2.4.1 DAC0,DAC1 The output waveform of
from machine import Pin,ADC,DAC
import utime
adc0 = ADC(0, init=True)
while True:
print(adc0.read_u16())
utime.sleep_ms(200)
stay PA0, Input DC voltage , You can test the output 0x0 ~ 0xffff The number . The output data is right aligned .
Be careful : first ADC When initializing , Need to put init=True Parameters are substituted into .
ADC All in all 16 Channels , The corresponding external ports are :
CH0~7
:PA0~PA7
CH8,CH9
:PB0,PB1
CH10~CH13
:PC0~PC3
CH14,CH15
:NULL
UART1
:PA10, PA9
UART2
:PA3,PA2
UART3
:PB11,PB10
UART4
:PC11,PC10
UART5
:PD2,PC12
UART6
:PC7,.PC6
UART7
:PE7,PE8
UART8
:PD1,PD0
from machine import Pin,UART
import utime
uart2 = UART(1, 115200)
print('Test UART.')
while True:
_ = uart2.write(b'U')
utime.sleep_ms(10)
stay PA2(TX2) Measure the output waveform .
▲ chart 2.6.1 PA2(TX2) The measured waveform
Use a short circuiting device to RXD3 And RXD1 come together , Also is to REPL Receive port of RXD1 Connected to the UART3 Receive port of .
from machine import Pin,UART
import utime
uart2 = UART(2, 115200)
print('Test UART.')
buf = bytes(0)
while True:
if uart2.any():
buf = buf + uart2.read(uart2.any())
if buf[-1] == 13:
print(int(buf))
buf = bytes(0)
utime.sleep_ms(10)
>> Reset MicroPython...
>> Wait for MicroPython coming back...
>> Download MicroPython : 33 lines/707 characters.
>> -------------------------------------------------------------------------
Test UART.
333
3333
123
Traceback (most recent call last):
File "<stdin>", line 22, in <module>
ValueError: invalid syntax for integer
>>>
adopt UART3 Send in DAC Convert numbers , Measure with a digital multimeter DAC0 Output voltage , And draw the output curve .
from headm import *
from tsmodule.tsstm32 import *
writedim = list(range(0, 0xfff, 40))
vdim = []
for w in writedim:
stm32cmd('SENDC%03d\r'%w)
time.sleep(1.5)
meter = meterval()
vdim.append(meter[0])
plt.plot(writedim, vdim)
plt.xlabel("Number")
plt.ylabel("Voltage(V)")
plt.grid(True)
plt.tight_layout()
plt.show()
printf('\a')
Here we get DAC The relationship between the conversion value and the output voltage . You can see that there is a very good relationship between them e linear relationship .
▲ chart 3.1.1 DAC Convert value to output voltage
from machine import DAC,ADC
import utime
adc0 = ADC(0, init=True)
dac0 = DAC(0)
vdim = []
outdim = list(range(0, 0xfff, 10))
print("Test DAC,ADC...")
for o in outdim:
dac0.write_u16(o)
utime.sleep_ms(2)
vdim.append(adc0.read_u16())
print(vdim)
from headm import *
from tsmodule.tsstm32 import *
stm32cmd('COPY')
time.sleep(.1)
allstr = clipboard.paste()
startid = allstr.find('[')
endid = allstr.find(']')
if startid < 0 or endid < 0:
printf("No data.\a")
exit()
datastr = [int(s) for s in allstr[startid + 1 : endid].split(',')]
printf(datastr)
plt.plot(datastr)
plt.xlabel("Number")
plt.ylabel("Voltage(V)")
plt.grid(True)
plt.tight_layout()
plt.show()
▲ chart 3.2.1 test result
Yes As of (2021-11-08 21:13:44) From smart MicroPython stay MM32F3277 Test the consistent basic functions on . And give in addition MicroPython Of the relevant modules の Basic test call version .
■ Links to related literature :
● Related chart Links :