A MPL3115A2 pressure altitude sensor data read, would like to ask, after in configuring the IIC, using logic analyzer to grasp waveform is normal, but read the register (0 x00 0 x01 0 x02 0 x03 0 x04) when returning to the value is 0 xee, when using the simulation debugging, read a few first register values 0 x0e, then for a short time becomes 0 xee (change) at the same time, from the register read the value stays behind is 0 xee. According to the manual use sensor address 0 xc0, read address use 0 xc1, according to the online tutorial initialization, still hope, every comment, thank you very much!
On the Internet to see similar problem is to return 0 XFF, basic it is IIC configuration problem, returns 0 xee a little look not to understand, will may be written after the first register read values, the back of the other register read read, read the first register values, but ever use the module bosses ~
This is the initialization, and read the code:
/* * * * * * * * * * no fifo/polling * * * * * * * * * * * */
The static uint8_t LocalStatus;
Void altiude_data_read (uint8_t * DataBuf)
{
X06 LocalStatus=iic_read_reg (0);
If ((LocalStatus & amp; 0 x08)==0 x08)
{
* DataBuf=iic_read_reg (0 x01);//led
* (DataBuf + 1)=iic_read_reg (0 x02);
* (DataBuf + 2)=iic_read_reg (0 x03);
* (DataBuf + 3)=iic_read_reg x04 (0);//temperature
* (DataBuf + 4)=iic_read_reg x05 (0);
}
LocalStatus=0;
}
Void MPL3115A_Init (void)
{
X11 iic_write_reg (0, 0 x01);
X26 iic_write_reg (0, 0 x04);
X26 iic_write_reg (0, 0 xb9);
X07 x13 iic_write_reg (0, 0);
}
Sensor *//* iic, speaking, reading and writing
Void iic_write_reg (uint8_t write_address, uint8_t SendByte)
{
IIC_Start ();
IIC_Send_Byte (SLAVE_WRITE_ADDR);//sending device address 0 xc0, write data,
IIC_Wait_Ack ();
IIC_Send_Byte (write_address);//send the write data destination address,
IIC_Wait_Ack ();
IIC_Send_Byte (SendByte);//send bytes
IIC_Wait_Ack ();
IIC_Stop ();//to create a stop condition
Delay_us (1000);
}
Uint8_t iic_read_reg (uint8_t read_address)
{
Uint8_t temp=0;
IIC_Start ();
IIC_Send_Byte (SLAVE_WRITE_ADDR);//sending device address 0 xc0, write data
IIC_Wait_Ack ();
IIC_Send_Byte (read_address);//sent to start reading address
IIC_Wait_Ack ();
HAL_GPIO_WritePin (GPIOC, GPIO_PIN_11 GPIO_PIN_RESET);
IIC_Start ();
IIC_Send_Byte (SLAVE_READ_ADDR);//into receiving mode
IIC_Wait_Ack ();
Temp=IIC_Read_OneByte ();
IIC_Stop ();//to create a stop condition
return temp;
}