2020-07-09 12:51 PM
I'm trying to send and receive data to and from a BH1750 and the microcontroler (NUCLEO-F446RE / STM32F446RE) onlyh sends a START when using the function HAL_I2C_Master_Transmit_DMA.
I used a logic analyser to try to see whats is going on (picture attached).
if(HAL_I2C_IsDeviceReady(&hi2c1, bh1750Address, 2, bh1750TimeOut) == HAL_OK){
__NOP();
}
transmitBuffer[0] = 0x10; // Continuous high res meas mode BH1750
HAL_I2C_Master_Transmit_DMA(&hi2c1, (uint8_t) bh1750Address, (uint8_t*)transmitBuffer, 1);
When I use the function "HAL_I2C_Master_Transmit"} everything works properly.
M'I doing something wrong? Is there a bug in the HAL driver?
Thanks!
2024-02-02 11:38 AM
I ran into exact same problem as yours. Fortunately, I found the solution. You should enable the I2C event interrupt. The functions inside will handle all events after START, including sending the slave address, reading specific flags, generating STOP, etc.
void I2C1_EV_IRQHandler(void) {
HAL_I2C_EV_IRQHandler(&hi2c1);
}
Maybe I'm too late. Hope you're still there. :crying_face: