How to use the API of CUBE to send date ''0x00'' with I2C1 ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2015-01-06 12:10 AM
Posted on January 06, 2015 at 09:10
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
Labels:
- Labels:
-
STM32Cube MCU Packages
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2015-01-07 4:51 AM
Posted on January 07, 2015 at 13:51
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.
