cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_I2C_Master_Transmit_DMA sends only a START and leave both I2C lines in low state.

GSouz.1
Associate

0693W000001sZw2QAE.pngI'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!

1 REPLY 1
Narukara
Associate

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: