2017-07-14 02:52 AM
Dear Sir/Madam,
I am working on STM32F405 mcu.
I developed my code on cubemx and HAL drivers.
I want to interface microchip adc 'MCP3428' via HAL I2C drivers but unfortunately i was failed.
Anybody of you please help me to resolved this issue.
Thank you.
Solved! Go to Solution.
2017-07-14 10:45 AM
status = HAL_I2C_Mem_Write(&hi2c1, // i2c handle
(uint16_t)(dev_addr<<1), // i2c address, left aligned (uint8_t)reg_addr, // register address I2C_MEMADD_SIZE_8BIT, // 8bit register addresses (uint8_t*)(®_data), // write returned data to variable named reg_data cnt, // write how many bytes 100); // timeoutyou'll have to read your data sheet for addresses and sizes, but the above code is how to read a register
2017-07-14 10:45 AM
status = HAL_I2C_Mem_Write(&hi2c1, // i2c handle
(uint16_t)(dev_addr<<1), // i2c address, left aligned (uint8_t)reg_addr, // register address I2C_MEMADD_SIZE_8BIT, // 8bit register addresses (uint8_t*)(®_data), // write returned data to variable named reg_data cnt, // write how many bytes 100); // timeoutyou'll have to read your data sheet for addresses and sizes, but the above code is how to read a register
2017-07-17 04:39 AM
Thank you so much.
My problem is solved.