cancel
Showing results for 
Search instead for 
Did you mean: 

I2C comunication doesn't work

DannyB
Visitor

Hello

I am trying to drive a MEMS mirror via I2C communication using the nucleo-h723zg board.

This is the clock configuration:

DannyB_2-1767105523319.png

DannyB_3-1767105553038.png

 

Then I activated the I2C1 as follow: 

DannyB_0-1767105458104.pngDannyB_1-1767105475047.png

 

I used the pins PB8 and PB9 for SCL and SDA:

DannyB_4-1767105652277.png

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:

DannyB_5-1767106007834.png

 

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

6 REPLIES 6
TDK
Super User

Does HAL_I2C_IsDeviceReady return HAL_OK? Start there. If not, here are some possibilities:

  • You're using the wrong slave address.
  • Slave is not powered.
  • Wiring is incorrect.
  • You are monitoring the wrong pins.

Slave address is shifted left 1 bit, so 0xC0 is the correct address here, not 0x60.

If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Super User

@DannyB wrote:

I used the pins PB8 and PB9 for SCL and SDA:


Have you checked that there's nothing on the Nucleo board already using these pins?

 


@DannyB wrote:

Using an oscilloscope and a multimeter I'm always measuring 0V and I can't see the SCL and SDA signals.


You seems to have some 3-to-5V translation going on, and at least 1 connector - so where, exactly, are you measuring?

 

The MCP4706 can work at 3V - so have you tried a direct connection?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

I checked the pin and it should be okay.

 

On the oscilloscope Im measuring directly on the I2C connector pins. With the Multimeter Im measunig on the output voltage of the DAC, so on the resistor R3.

 

No, I didn't tried a direct connection 


@DannyB wrote:

I checked the pin and it should be okay.


You need to check two pins: PB8 and PB9

 


@DannyB wrote:

On the oscilloscope Im measuring directly on the I2C connector pins.


Which I2C connector ?

How are you connecting to the Nucleo board ?

The default is that PB8 & PB9 are not connected to the Zio headers:

AndrewNeil_1-1767109035366.png

https://www.st.com/resource/en/user_manual/um2407-stm32h7-nucleo144-boards-mb1364-stmicroelectronics.pdf#page=34

via: https://www.st.com/en/evaluation-tools/nucleo-h723zg.html#documentation

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

The I2C connector on the PCB (called H2 on the schematic).

I'm connecting the nucleo board on my PC using the USB cable to the USB PWR on the board and 2 cables from the pins PB8 (which is D15-SCL) and PB9 (which i D14-SDA) on the CN7 connector to the PCB (component H2 on the schematic).

I'm giving the digital value from the microcontroller to the external DAC. So it's right that it's not connected to CN9 or am I wrong?

Not clear what you mean by "the PCB" and "the board"?

A Nucleo is a "board" aka a "PCB"; presumably, your MCP4706 is on a separate PCB?

You've only shown a tiny part of the MCP4706 board.

 

Please show a block diagram (or schematic) of the complete system.

 

How to write your question to maximize your chances to find a solution


A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.