当前位置:网站首页>Mindmotion mm32f3277 softi2c Function Test
Mindmotion mm32f3277 softi2c Function Test
2021-11-25 17:26:08 【Zhuo Qing】
Jane. Suke: Pour lesMindMotion SuYongEnvoyé avecSoftI2C Pour tester la version portable de.Il a été prouvé à titre préliminaire queSoftI2CFonction de migration. UtilisationOLEDAfficher les tests,Vous pouvez voir cette version deSoftI2CLes commandes du bus externe sont très lentes.Testé,Vous pouvez voir cette version deSoftI2CLe contrôle de l'horloge de sortie n'est pas prêt.
Mots clés
: I2C,MM32,MicroPython
§01 MM32F3277 MicroPython
Aujourd'huiOh, mon Dieu.(2021-11-25)Bien reçu.MindMotion SuYongEnvoyé pourMM32F3277DeMicroPythonAjouterI2CVersion portable de la fonction bus.
Bleu clair[SY]:
M. Zhuo.,Ces deux derniers jours, c'était juste un truc comme ça
Bleu clair[SY]:
Matérieli2cDrive, J'ai besoin de mon couteau.
Bleu clair[SY]:
Sisoft i2cÇa marche, Je vais commencer par le matériel. spi Optimisation et pwm Extension du canal
Bleu clair[SY]:
Ça pourrait nous aider. i2c Un peu de temps pour les collègues entraînés par le matériel , Qu'elle change de code. , Ou s'il vous plaît, aidez - moi.
- Télécharger l'adresse: firmware-2021-11-25
Cette version est testée ci - dessous .
Un.、Tests MicroPython
1、Oui.MicroPythonTélécharger àMCU
▲ Fig.1.1.1 TéléchargerMicroPythonÀMM32F3277
2、Essais préliminaires
(1)REPL TestsmachineModule
>>> import machine
>>> dir(machine)
['__name__', 'ADC', 'DAC', 'PWM', 'Pin', 'SDCard', 'SPI', 'SoftI2C', 'SoftSPI', 'UART', 'freq', 'mem16', 'mem32', 'mem8']
>>>
3、Test de programmation
PourMicroPythonÀ propos deI2C Pour la documentation programmée, voir : MicroPython class I2C
▲ Fig.1.1.2 I2C Cas d'utilisation
(1)Essais préliminaires
Ⅰ.Procédure d'essai
from machine import I2C
import utime
i2c = I2C(freq400000)
i2c.scan()
i2c.writeto(42, b'123')
Ⅱ.Résultats obtenus
>> Download MicroPython : 22 lines/515 characters.
>> -------------------------------------------------------------------------
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
ImportError: can't import name I2C
>>>
(2)import SoftI2C
Ⅰ.Code d'essai
from machine import Pin,SoftI2C
i2c = SoftI2C(freq400000)
i2c.scan()
i2c.writeto(42, b'123')
Ⅱ.Résultats obtenus
>> Download MicroPython : 22 lines/524 characters.
>> -------------------------------------------------------------------------
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
ImportError: module not found
>>>
4、Port d'essai
2.、TestsI2C OLED
In Lexinesp8266ModuleMicroPythonConseil de développementMQTTInternet des objets système minimal d'intelligence artificielle Testé I2C OLEDModule, Connectez - le ci - dessous à MM32F3277Allez..
1、ConnexionOLED
▲ Fig.1.2.1 Sur la planche à pain, Amiral. OLED Fixé au tableau d'essai
2、Essais préliminaires
(1) Scan bus
Ⅰ.Code d'essai
from machine import Pin,SoftI2C
import utime
print("Test I2C")
scl = Pin('PA0')
sda = Pin('PA1')
i2c = SoftI2C(scl, sda, freq=100000)
ret = i2c.scan()
print(ret)
Ⅱ.Résultats obtenus
>> Download MicroPython : 26 lines/584 characters.
>> -------------------------------------------------------------------------
Test I2C
[60]
>>>
D'en hautscanJe l'ai.I2CDeSlaveL'adresse de60(0x3C),Ceci est lié à Lexinesp8266ModuleMicroPythonConseil de développementMQTTInternet des objets système minimal d'intelligence artificielle Les adresses données sont cohérentes .
(2)Test Write
Ⅰ.Code d'essai
from machine import Pin,SoftI2C
import utime
from micropython import const
scl = Pin('PA0')
sda = Pin('PA1')
i2c = SoftI2C(scl, sda, freq=100000)
ret = i2c.scan()
print(ret)
temp = bytearray(2)
i2c.start()
temp[0] = 120
temp[1] = 1
i2c.write(temp)
i2c.stop()
print('Test end.')
Ⅱ.Résultats obtenus
>> Download MicroPython : 34 lines/760 characters.
>> -------------------------------------------------------------------------
[60]
2
Test end.
>>>
Vous pouvez voir écrire deux octets .
3、InitialisationOLED
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# TESTI2C.PY -- by Dr. ZhuoQing 2021-11-25
#
# Note:
#============================================================
from machine import Pin,SoftI2C
import utime
from micropython import const
#------------------------------------------------------------
scl = Pin('PA0')
sda = Pin('PA1')
i2c = SoftI2C(scl, sda, freq=100000)
#------------------------------------------------------------
SET_CONTRAST = const(0x81)
SET_ENTIRE_ON = const(0xa4)
SET_NORM_INV = const(0xa6)
SET_DISP = const(0xae)
SET_MEM_ADDR = const(0x20)
SET_COL_ADDR = const(0x21)
SET_PAGE_ADDR = const(0x22)
SET_DISP_START_LINE = const(0x40)
SET_SEG_REMAP = const(0xa0)
SET_MUX_RATIO = const(0xa8)
SET_COM_OUT_DIR = const(0xc0)
SET_DISP_OFFSET = const(0xd3)
SET_COM_PIN_CFG = const(0xda)
SET_DISP_CLK_DIV = const(0xd5)
SET_PRECHARGE = const(0xd9)
SET_VCOM_DESEL = const(0xdb)
SET_CHARGE_PUMP = const(0x8d)
#------------------------------------------------------------
class SSD1306():
def __init__(self, width, height, external_vcc):
self.width = width
self.height = height
self.external_vcc = external_vcc
self.pages = self.height // 8
self.buffer = bytearray(self.pages * self.width)
self.init_display()
def init_display(self):
for cmd in (
SET_DISP | 0x00, # off
SET_MEM_ADDR, 0x00, # horizontal
SET_DISP_START_LINE | 0x00,
SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0
SET_MUX_RATIO, self.height - 1,
SET_COM_OUT_DIR | 0x08, # scan from COM[N] to COM0
SET_DISP_OFFSET, 0x00,
SET_COM_PIN_CFG, 0x02 if self.height == 32 else 0x12,
SET_DISP_CLK_DIV, 0x80,
SET_PRECHARGE, 0x22 if self.external_vcc else 0xf1,
SET_VCOM_DESEL, 0x30, # 0.83*Vcc
SET_CONTRAST, 0xff, # maximum
SET_ENTIRE_ON, # output follows RAM contents
SET_NORM_INV, # not inverted
SET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14,
SET_DISP | 0x01): # on
self.write_cmd(cmd)
self.fill(0xff)
self.show()
def fill(self, c):
for i in range(len(self.buffer)):
self.buffer[i] = c
def poweroff(self):
self.write_cmd(SET_DISP | 0x00)
def poweron(self):
self.write_cmd(SET_DISP | 0x01)
def contrast(self, contrast):
self.write_cmd(SET_CONTRAST)
self.write_cmd(contrast)
def invert(self, invert):
self.write_cmd(SET_NORM_INV | (invert & 1))
def show(self):
x0 = 0
x1 = self.width - 1
if self.width == 64:
x0 += 32
x1 += 32
self.write_cmd(SET_COL_ADDR)
self.write_cmd(x0)
self.write_cmd(x1)
self.write_cmd(SET_PAGE_ADDR)
self.write_cmd(0)
self.write_cmd(self.pages - 1)
self.write_data(self.buffer)
class SSD1306_I2C(SSD1306):
def __init__(self, width, height, i2c, addr=0x3c, external_vcc=False):
self.i2c = i2c
self.addr = addr
self.temp = bytearray(2)
super().__init__(width, height, external_vcc)
def write_cmd(self, cmd):
self.temp[0] = 0x80 # Co=1, D/C#=0
self.temp[1] = cmd
self.i2c.writeto(self.addr, self.temp)
def write_data(self, buf):
self.temp[0] = self.addr << 1
self.temp[1] = 0x40 # Co=0, D/C#=1
self.i2c.start()
self.i2c.write(self.temp)
self.i2c.write(buf)
self.i2c.stop()
#------------------------------------------------------------
oled = SSD1306_I2C(128, 64, i2c, addr=0x3c)
#oled.text('Hello world!', 0, 0)
#oled.text('OLED test', 0, 50)
#oled. show()
#------------------------------------------------------------
# END OF FILE : TESTI2C.PY
#============================================================
En basOLED Écrire pendant l'initialisation 1024 Procédure en octets , Processus anormalement lent .
▲ Fig.1.2.2 RafraîchirOLEDProcessus
C'est si lent. ,Réussir l'essai oscilloscopeSCL,SDALa forme d'onde de, Vous pouvez voir que le taux de Baud à ce stade n'est que 400Hz, Très différent du taux de Baud initialisé .
▲ Fig.1.2.3 I2C Processus d'écriture du bus
※ MesureRésumé des essais ※
C'est exact. Yu - cong MindMotion SuYongEnvoyé avecSoftI2C Pour tester la version portable de.Il a été prouvé à titre préliminaire queSoftI2CFonction de migration. UtilisationOLEDAfficher les tests,Vous pouvez voir cette version deSoftI2CLes commandes du bus externe sont très lentes.
Testé,Vous pouvez voir cette version deSoftI2CLe contrôle de l'horloge de sortie n'est pas prêt.
■ Liens vers des documents connexes:
- firmware-2021-11-25
- MicroPython class I2C
- Lexinesp8266ModuleMicroPythonConseil de développementMQTTInternet des objets système minimal d'intelligence artificielle
● Liens graphiques connexes:
版权声明
本文为[Zhuo Qing]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/11/20211125172128774p.html
边栏推荐
- ML2021 | (腾讯)PatrickStar:通过基于块的内存管理实现预训练模型的并行训练
- 元宇宙最缺的是内容,而云计算能帮上忙
- SIMXXX NDIS dials and starts automatically after booting
- 面试官会问你 最近读的一篇paper
- C# datagridview、datagrid、GridControl增加行号
- 惊喜,我克隆了对象的的声音
- 行业分析| 大势所趋:元宇宙
- 如何在GEC-6818上绘制彩虹图?
- WGS84(GPS)、火星坐标系(GCJ02)、百度地图(BD09)坐标系转换案例教程(附转换工具下载)
- EasyNVR视频点击开始录像提示“创建录像文件失败”,是什么原因导致的?
猜你喜欢
-
29.轮廓发现
-
ML2021 | (腾讯)PatrickStar:通过基于块的内存管理实现预训练模型的并行训练
-
29.輪廓發現
-
29. Contour Discovery
-
Easynvr Video Click to start Video prompt "CREATE Video file failed", What causes?
-
WGS84 (GPS), mars Coordinate System (gcj02), baidu Map (bd09) Coordinate System Conversion Case tutoriel (with conversion Tool Download)
-
Comment dessiner un arc - en - ciel sur le GEC - 6818?
-
节卡机器人获 C+ 轮融资,半年内完成两轮
-
腾讯加码移动机器人赛道-投资蓝芯科技
-
从RPA到超自动化,「弘玑Cyclone」获1.5亿美元C轮融资
随机推荐
- LR Approval Process Design, one - stop Solution to Office Problems
- Ml2021 | (Tencent) Patrick Star: mise en œuvre de la formation parallèle du modèle de pré - formation par la gestion de la mémoire par blocs
- Meilleures pratiques pour les entrepôts de données en temps réel de Wechat clickhouse
- (C language) implementation of Sanzi chess
- 從RPA到超自動化,「弘璣Cyclone」獲1.5億美元C輪融資
- De RPA à super Automation, hongji cycline a reçu 150 millions de dollars de financement de la série C
- Piste de robots mobiles Tencent plus Code - Investir dans la technologie Blue Core
- 容器探针-健康检查
- Le robot économiseur de cartes a obtenu le financement de la ronde C +, et deux rondes ont été achevées dans un délai de six mois.
- Sonde du récipient - bilan de santé
- 回顾“低代码”历史发展,是技术进步了还是倒退了?
- 坐标东京,诚招IT工程师
- 神奇的色调旋转滤镜hue-rotate
- EasyPlayerJS可以看见码率但是无法播放视频,是什么原因?
- RFID高频14443协议 大功率读写器/远距离读写器
- IO流实现深克隆
- IO流實現深克隆
- Io Stream implémentation of Deep cloning
- RFID High Frequency 14443 Protocol High Power Reader / Remote Reader Writer
- Easyplayerjs peut voir le débit mais ne peut pas lire la vidéo, quelle est la raison?
- Filtre rotatif de teinte magique Hue rotate
- Coordonnées Tokyo, recrutement d'ingénieurs informatiques
- Si l'on examine l'évolution historique du « faible Code », la technologie a - t - elle progressé ou régressé?
- Analyse de l'industrie | tendance générale: métacosme
- [学习报告]《LeetCode零基础指南》(第四讲) 一维数组)
- During the job interview, what means does HR have to know your marriage and childbirth?
- [學習報告]《LeetCode零基礎指南》(第四講) 一維數組)
- [rapport d'étude] leetcode Zero Basic Guide (session 4) 1D Array)
- Tips for promotion and salary increase of IT personnel large factory vs small factory
- Visual studio 2022 has been released. Here are my five favorite features!
- Performance problem analysis of yyds dry goods inventory how to eliminate invalid test
- Visual studio 2022 has been released. Here are my five favorite features!
- Black Hat Europe 2021议题解读:Wi-Fi Mesh中的安全攻击面
- CWE4.6标准中加入 OWASP 2021 TOP10
- 【并发技术系列】「多线程并发编程」技术体系和并发模型的基础探究(夯实基础)
- META|PyTorchVideo:用于视频理解的深度学习库
- Surprise, j'ai cloné la voix de l'objet.
- Ajouter le numéro de ligne pour C # datagridview, datagrid, gridcontrol
- 被下属骂,记一次矛盾升级——有心无心,蝴蝶效应?
- 被下屬罵,記一次矛盾昇級——有心無心,蝴蝶效應?