2015-01-06 12:10 AM
I have a temperature sensor,the TMPToday I want to test it with I2C,I have test it withStandard Library,I can read it with NUCLEO stm32f072 board.But when i use the cubeLibrary to read it,it's break.I have used theFunction ''HAL_I2C_Master_Receive()'',this is my code of send reg address ''0x00'',it breaked when i send it.
void TMP275_Read(void)
{
TxBuffer
while(HAL_I2C_Master_Transmit(&hi2c1,(uint16_t) I2C1_WRITE_ADDRESS,(uint8_t*) TxBuffer, 1, 1000)!= HAL_OK)
{
/* Error_Handler() function is called when Timout error occurs.
When Acknowledge failure ocucurs (Slave don't acknowledge it's address)
Master restarts communication */
if (HAL_I2C_GetError(&hi2c1) != HAL_I2C_ERROR_AF)
{
Error_Handler();
}
}
while(HAL_I2C_Master_Receive(&hi2c1, (uint16_t)I2C1_READ_ADDRESS,(uint8_t*) aRxBuffer, 2, 1000)!= HAL_OK)
{
/* Error_Handler() function is called when Timout error occurs.
When Acknowledge failure ocucurs (Slave don't acknowledge it's address)
Master restarts communication */
if (HAL_I2C_GetError(&hi2c1) != HAL_I2C_ERROR_AF)
{
Error_Handler();
}
}
}
when i read it ,i have initialized the TMP275,There is the code:
void TMP275_Init(void)
{
aTxBuffer[0]=0x01;
aTxBuffer[1]=0xfe;
//aTxBuffer[2]=0x00;
while(HAL_I2C_Master_Transmit(&hi2c1,(uint16_t) I2C1_WRITE_ADDRESS,(uint8_t*) aTxBuffer, 2, 1000)!= HAL_OK)
{
/* Error_Handler() function is called when Timout error occurs.
When Acknowledge failure ocucurs (Slave don't acknowledge it's address)
Master restarts communication */
if (HAL_I2C_GetError(&hi2c1) != HAL_I2C_ERROR_AF)
{
Error_Handler();
}
}
}
#stm32-hal-i2c
2015-01-07 04:51 AM
At which level is it broken?
-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.