2022-04-29 02:19 PM
2022-04-29 02:38 PM
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)
2022-04-29 02:45 PM
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.
2022-04-29 02:45 PM
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.
2022-04-29 02:47 PM
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.
2022-04-29 02:49 PM
//****************************************************************************
/**
* @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);
}
//****************************************************************************
2022-04-29 03:27 PM
@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 ?
2022-04-29 03:32 PM
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.
2022-04-29 03:40 PM
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
2022-04-29 03:53 PM
thank you. i will look into it.