Skip to main content
ZJing
Associate III
September 16, 2023
Solved

L431 Stops working after enabling ADC

Hello all,

I recently ran into this problem where the MCU would instantly stop working after enabling the DAC. The behavior is that from the debug view of STM32IDE the program is still running, but all variable values are reset to 0, and once the program is paused manually, instead of showing where exactly the program was paused at, it shows a blank window with some HEX address.

 

Below is the DAC connection schematic:

ZJing_0-1694859495061.png

The DAC output pin is connected to an op-amp and a bjt to drive the 5 turns coil

Below is the GPIO and DAC init codes:

	/*TOUT GPIO Configuration

	PA4 ------> TOUT

	*/

	GPIO_InitStruct.Pin = TOUT_PIN;
	GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
	GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
	LL_GPIO_Init(TOUT_PORT, &GPIO_InitStruct);
static void DAC_Init(void)
{

	LL_DAC_InitTypeDef DAC_InitStruct = {0};

	/* Peripheral clock enable */
	LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_DAC1);

	/** DAC channel OUT1 config
	*/
	DAC_InitStruct.TriggerSource = LL_DAC_TRIG_SOFTWARE;
	DAC_InitStruct.WaveAutoGeneration = LL_DAC_WAVE_AUTO_GENERATION_NONE;
	DAC_InitStruct.OutputBuffer = LL_DAC_OUTPUT_BUFFER_ENABLE;
	DAC_InitStruct.OutputConnection = LL_DAC_OUTPUT_CONNECT_GPIO;
	DAC_InitStruct.OutputMode = LL_DAC_OUTPUT_MODE_NORMAL;
	LL_DAC_Init(DAC1, LL_DAC_CHANNEL_1, &DAC_InitStruct);
	LL_DAC_DisableTrigger(DAC1, LL_DAC_CHANNEL_1);

}

 

What could cause this behavior? Any idea/suggestion would be greatly appreciated!

 

Zhi

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
September 16, 2023

Check VDDA vs NRST on a scope.

Make sure ALL supply pins are suitable connected

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

5 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
September 16, 2023

Check VDDA vs NRST on a scope.

Make sure ALL supply pins are suitable connected

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ZJing
ZJingAuthor
Associate III
September 18, 2023

Thank you! I did not connect one of the supply pins. That was the problem

Tinnagit
Senior II
September 16, 2023

I'm unsure about Low Level Initial but it has require define USE_FULL_LL_DRIVER to use function in Low Level Driver. and Is that you had define it already?

TDK
September 16, 2023

Pin 19 needs connected to power, as @Tesla DeLorean says. Could be other schematic errors, show the full schematic if you can.

TDK_0-1694873144480.png

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
ZJing
ZJingAuthor
Associate III
September 18, 2023

I did forget to connect that pin, so yes it was the problem