cancel
Showing results for 
Search instead for 
Did you mean: 

Can anybody help me how to translate this for my nucleo?

Myilm.1
Associate II
 
21 REPLIES 21

What NUCLEO / STM32 ? Narrow it down a little.

Don't post code as graphics, these can't be cut-n-pasted, use the code entry tool, see </> icon at bottom of post entry window

Use HAL_I2C_Mem_Write() with an 8-bit memory address for the channel.

Shift the I2C address left to match ST's usage, ie (i2c_addr << 1)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

From the MAX518 info page, its "wire" interface is compatible with I2C,

and your Nucleo likely has I2C controller (or several).

Look for I2C examples in the ST software pack for your Nucleo.​

Myilm.1
Associate II

Thank you for your reply. Yes STM32. Nucleo-F767ZI. Is it possible to write it more clear? Because I am very new to ​STM. Just would like to test my max518 DAC IC with the dev. board.

Thank you indeed.

Thank you for your reply. Yes STM33. Nucleo-F767ZI. Is it possible to write it more clear? Because I am very new to ​STM. Just would like to test my max518 DAC IC with the dev. board.

Thank you indeed.

//****************************************************************************
 
/**
  * @brief  Writes a single data.
  * @param  Addr: I2C address
  * @param  Reg: Register address
  * @param  Value: Data to be written
  * @retval None
  */
static int I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
{
  HAL_StatusTypeDef status = HAL_OK;
 
  status = HAL_I2C_Mem_Write(&I2CHandle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, &Value, 1, 100);
 
  /* Check the communication status */
  if (status != HAL_OK)
  {
    /* Execute user timeout callback */
    I2Cx_Error(Addr); // User Supplied Routine
  }
 
	return((int)status);
}
 
//****************************************************************************

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

@Myilm.1​  "I am very new to ​STM."

Are you familiar with any other microcontroller(s) ?

Are you familiar with the basics of I2C in general ?

I worked with PIC and Atmel when i was studying at university but at the moment i work as a hardware engineer. But i would like to develop myself on programming. I am not much familiar with i2c to be honest but would like to learn more.

Pavel A.
Evangelist III

There is Arduino-like environment for STM32, it has a "Wire" driver implemented over I2C.

https://github.com/stm32duino/Arduino_Core_STM32/tree/main/libraries/Wire

thank you. i will look into it.