2025-12-30 6:51 AM
Hello
I am trying to drive a MEMS mirror via I2C communication using the nucleo-h723zg board.
This is the clock configuration:
Then I activated the I2C1 as follow:
I used the pins PB8 and PB9 for SCL and SDA:
I'm using the DAC called MCP47x6A0T, so the address should be:
static const uint8_t DAC_Address= 0x60;
Then I give an input data:
static const uint8_t MEMS_Digital_Input2= 0x1C;
and then I use the function Master Transmit in the while loop:
HAL_I2C_Master_Transmit(&hi2c1, DAC_Address, MEMS_Digital_Input2, 1, HAL_MAX_DELAY);
I've this circuit connected to the microcontroller:
Using an oscilloscope and a multimeter I'm always measuring 0V and I can't see the SCL and SDA signals.
Do you know where am I doing wrong?
Kind regards
2025-12-31 1:29 AM
@TDK I fixed the slave address but nothing is changed. I've to check the HAL_I2C_IsDeviceReady function.
Because @Andrew Neil when I measure with the oscilloscope both signals are at 0V. So it seems I have no output signal from the microcontroller.
2025-12-31 1:38 AM
@DannyB wrote:I measure with the oscilloscope both signals are at 0V
You still haven't said where, exactly, you did this measurement!
@DannyB wrote:
There needs to be a GND connection between the Nucleo and the mirror PCB.
2026-01-02 2:33 AM - last edited on 2026-01-02 4:39 AM by Andrew Neil
I'm measuring on the PB8 and PB9 pins as shown below:
Now I can see the SCL signal but on the SDA signal I see only the slave address, the data is always 0.
I'm trying to send the MEMS_Input2.
When I send the function HAL_I2C_Master_Transmit(&hi2c1, DAC_Address, MEMS_Digital_Input2, 1, HAL_MAX_DELAY);
I've a warning telling this:
Is that the problem for the data always at 0?
2026-01-02 4:49 AM - edited 2026-01-02 4:56 AM
@DannyB wrote:Now I can see the SCL signal
Previously you said you were seeing nothing - So what changed?
Please show a trace of what you see - using your scope's screen capture facility rather than a photo.
Please see How to insert source code - not as screenshots.
@DannyB wrote:When I send the function
HAL_I2C_Master_Transmit( &hi2c1, DAC_Address, MEMS_Digital_Input2, 1, HAL_MAX_DELAY );I've a warning telling this:
See the documentation of the HAL_I2C_Master_Transmit function:
There you can see that argument 3 is pData - which is a pointer to a uint8_t.
But your code supplies MEMS_Digital_Input - which is an actual uint8_t:
You need to pass a pointer to that variable.
PS:
Note that the documentation of the HAL functions is provided in the source:
/**
* @brief Transmits in master mode an amount of data in blocking mode.
* @PAram hi2c Pointer to a I2C_HandleTypeDef structure that contains
* the configuration information for the specified I2C.
* @PAram DevAddress Target device address: The device 7 bits address value
* in datasheet must be shifted to the left before calling the interface
* @PAram pData Pointer to data buffer
* @PAram Size Amount of data to be sent
* @PAram Timeout Timeout duration
* @retval HAL status
*/
HAL_StatusTypeDef HAL_I2C_Master_Transmit( I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout )
2026-01-02 6:01 AM
@Andrew Neil as you said I added a GND connection between the Nucleo and the mirror PCB usign the GND of one of the probes.
This is what I see: