MCP3464微食
我想阅读具有ESP32的MCP 3464转换的结果 我可以阅读寄存器并写寄存器。 但是,当我想阅读转换的结果时,结果始终相同:b'\ x00 \ x00'
from machine import Pin, SPI, SoftSPI
from time import sleep_ms
sck = Pin(18, Pin.OUT)
mosi = Pin(23, Pin.OUT)
miso = Pin(19, Pin.IN)
cs = Pin(17, Pin.OUT)
cs.value(1)
spi = SoftSPI(baudrate=400000, polarity=0, phase=0, sck=sck, mosi=mosi, miso=miso)
spi.init()
def lecture():
#lecture
cs.value(0)
spi.write(b'\x41')
val = spi.read(2)
print(val)
cs.value(1)
lecture()
读取值时,我找到的值是不同寄存器的配置:01110011:01110011
CONFIG0 : b'\xc0'
CONFIG1 : b'\x0c'
CONFIG2 : b'\x8b'
CONFIG3 : b'\x00'
IRQ : b'ss'
这是当我读取示波器的
MUX : b'\x01'
SCAN : b'\x00\x00\x00'
TIMER : b'\x00\x00\x00'
OFFSETCALL : b'\x00\x00\x00'
GAINCAL : b'\x80\x00\x00'
RESERVED : b'\x90\x00\x00'
RESERVED : b'PPP'
LOCK : b'\xa5'
RESERVED : b'\x00\x0b'
CRCCFG : b'\x00\x00'
I want to read the result of a conversion of the MCP 3464 with a ESP32
I can read registers and write registers.
But when I want to read the result of conversion the result is always the same : b'\x00\x00'
from machine import Pin, SPI, SoftSPI
from time import sleep_ms
sck = Pin(18, Pin.OUT)
mosi = Pin(23, Pin.OUT)
miso = Pin(19, Pin.IN)
cs = Pin(17, Pin.OUT)
cs.value(1)
spi = SoftSPI(baudrate=400000, polarity=0, phase=0, sck=sck, mosi=mosi, miso=miso)
spi.init()
def lecture():
#lecture
cs.value(0)
spi.write(b'\x41')
val = spi.read(2)
print(val)
cs.value(1)
lecture()
This is the configuration of the different registers when I do a read
CONFIG0 : b'\xc0'
CONFIG1 : b'\x0c'
CONFIG2 : b'\x8b'
CONFIG3 : b'\x00'
IRQ : b'ss'
when I read the value with an oscilloscaop I found : 01110011
MUX : b'\x01'
SCAN : b'\x00\x00\x00'
TIMER : b'\x00\x00\x00'
OFFSETCALL : b'\x00\x00\x00'
GAINCAL : b'\x80\x00\x00'
RESERVED : b'\x90\x00\x00'
RESERVED : b'PPP'
LOCK : b'\xa5'
RESERVED : b'\x00\x0b'
CRCCFG : b'\x00\x00'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否考虑过使用支持更快的传输速率?
特别是当您使用最佳引脚与ESP32硬件SPI BUS 2一起使用时。
此外,根据传感器的不同,传感器通常需要一些时间才能在SPI总线上读取,转换和返回所需的数据。
数据表应该告诉您最小所需的时机,但对于初始调试,以
time.sleep_ms(100)
或类似的延迟开始。Have you considered using the ESP32 Hardware.SPI bus that supports much faster transmission rates ?
especially as you are using the optimal pins for use with the ESP32 Hardware SPI bus 2.
In addition, depending on the sensor, it usually takes some time for the sensor to read, convert, and return the requested data on the SPI bus.
The datasheet should tell you the minimum required timing, but for initial debugging start with an ample delay of
time.sleep_ms(100)
or similar.