STM32L0 - I2C - Bug in HAL_I2C_Master_Sequential_Transmit ?
Hallo,
I am trying to Read GPS data from a uBlox LEA via I2C with a STM32L073RZ (Nucleo Board). I am able to read EEPROMs with the HAL Libraries in Blocking and Interrupt Mode. The EEPROM i am using is a 24LC64 and it is not critical to I2C Specifications so I can read it using a HAL_transmit to tell the Adress I want to read and then use a HAL_read to read the number of Bytes. Unfortunately the HAL functions automatically generates a STOP condition after using it! My problem is, that the GPS chip I want to read strictly follows the I2C specifications and does Expect a RESTART/START condition in between the Transmit – Read actions and does not accept a STOP.
Here I come the Combined Transactions from HAL Lib into the game. With these functions I was able to solve the I2C combined transaction Problem using the Transfer Options provided.
HAL_I2C_Master_Sequential_Transmit_IT
(hi2c, DevAddress, addr, 1, I2C_FIRST_FRAME);
HAL_I2C_Master_Sequential_Receive_IT
(hi2c, DevAddress, pData, len, I2C_LAST_FRAME);
Using my Logic Analyzer, I can See the I2C connection working and transfer Data correctly. The Data decrypted via the logic analyzer makes sense. All Adresses and read / write transactions are correct on the logic analyzer. My Problem is, that the HAL_I2C_Master_Sequential_Reveive_IT function doesn’t write Data in via the Pointer pData back in Buffer! So I can see everything works, but I don’t get the data back ? Did I just encounter a Library Bug? Do I use the function correctly?
Function:
HAL_StatusTypeDef I2C_uBlox_Read_SQ(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData, uint16_t len) {
HAL_StatusTypeDef returnValue; uint8_t addr[2];addr[1] = (uint8_t) ((MemAddress & 0xFF00) >> 8);
addr[0] = (uint8_t) (MemAddress & 0xFF);returnValue = HAL_I2C_Master_Sequential_Transmit_IT(hi2c, DevAddress, addr, 1, I2C_FIRST_FRAME);
if(returnValue != HAL_OK) return returnValue; HAL_Delay(1); returnValue = HAL_I2C_Master_Sequential_Receive_IT(hi2c, DevAddress, pData, len, I2C_LAST_FRAME); return returnValue;}Function Call:
#define BUFFER_SIZE 500
uint8_t bufferI2C_uint8[BUFFER_SIZE];
I2C_uBlox_Read_SQ(&hi2c1, UBLOX_I2C_SHIFTED_ADRESS, 0xFD , bufferI2C_uint8, (2) );
I2C_uBlox_Read_SQ(&hi2c1, UBLOX_I2C_SHIFTED_ADRESS, 0xFF , bufferI2C_uint8, (200 ) );
