|
最近客户在调试YBX-BMP581气压传感器模块时,通过SPI连接的方式可以读取到正确的数据,但是使用I2C方式无法读取数据。每次上电时,串口上显示数据:bmp5_init Error -5 : Power up error.。
首先和客户确认硬件连接。之前,我们在帖子《使用STM32开发板连接BMP581传感器读取大气压力值》中详细介绍了SPI和I2C的硬件连接,客户为排除杜邦线接触不良的原因,将线之间焊接到模块上,并将线长度调短。
在代码中,查找打印输出语句所在的位置,发现是power_up_check()函数运行错误时才会报该错误。在这个API函数中,主要是用于验证上电后过程。 在手册中描述的具体上电过程如下: After power up of the BMP581, it is available after t_powerup. The host should not initiate any communication with the
BMP581 before. Depending on the interface configuration, a dummy read should be the first access to the device (see
4.1).
It is recommended that the host checks the following status registers after a power-up:
read out the CHIP_ID register and check that it is not all 0
read out the STATUS register and check that status_nvm_rdy==1, status_nvm_err == 0
read out the INT_STATUS.por register field and check that it is set to 1; that means INT_STATUS==0x10
用户在线调试,发现读取到的chip_id变量值是0xA0。查询手册,BMP581的芯片ID的寄存器位于0x01,默认值是0x50。 使用示波器和逻辑分析仪查看读取到的波形,发现发送的I2C地址与实际的不符。
YBX-BMP581模块的默认I2C地址是0x47,SDO引脚上拉至VDD。将代码中的I2C地址改为BMP5_I2C_ADDR_SEC,数据正常读取。
|