2024-09-30 06:28 AM
Hello everyone,
I'm working on a project with an STM32F446RE, a MCP4725 DAC, and a potentiometer to simulate the throttle of an electric racing motorcycle. My goal is to read the potentiometer value through the ADC of the STM32 and then transmit it via I2C to the MCP4725 to generate a proportional output voltage based on the potentiometer's position.
STM32F446RE:
MCP4725 DAC:
Potentiometer:
The issue I'm encountering is that, although the ADC value changes correctly when I move the potentiometer (verified through debugging), the HAL_I2C_Master_Transmit function to send the value to the MCP4725 doesn't execute properly. The data transmission gets stuck at this line, and there is no change in the DAC's output voltage (it remains fixed at 1.62V).
What I've tried so far:
Any advice or suggestions would be greatly appreciated.
2024-09-30 06:42 AM
@Soniaa12 wrote:The data transmission gets stuck at this line, .
What line?
Are you getting ant error return codes from the HAL functions?
Have you looked at the I2C lines with an oscilloscope or logic analyser to see what (if anything) is happening?
I would suggest that you forget about the ADC, DMA, etc for now and write a simple app which just handles the DAC.
Once you have that tested & working, then mode on to integrating it with the DAC stuff.