Skip to main content
AElgh
Associate III
January 26, 2024
Question

STM32WL with RGB, TIM16, PWM & DMA

  • January 26, 2024
  • 2 replies
  • 2470 views

Hello Everyone, I'm driving the WS2812 RGB-LED using TIM16 CH1.

I have a very similar behavior as in this_post . The RGB works well just until MX_LoRaWAN_Process(void) then it doesn't work. I tried his solution but it didn't work(although I suspect the SYSTICK is not working).

 

The Waveform looks like this:

AElgh_1-1706290666482.png

 

The solution in the post(using the following lines) didn't work for me:

 /* Wake up from STOP2 on button press */
 SystemClock_Config();
 HAL_ResumeTick();
 MX_TIM16_Init();

 

I also printed out the content of the LED_DATA_ARRAY(which contains the color data) and it seems fine.

The Mode is STOP-Mode2. What would be the problem here?

 

Thank you

Amir

 

2 replies

STTwo-32
Technical Moderator
March 5, 2024

Hello @AElgh 

Are you disabling the Timer clock before entering the STOP Mode. If so, try to keep it enabled.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
AElgh
AElghAuthor
Associate III
June 30, 2024

Hi

This issue comes when I deactivate the  Debugger(DEBUGGER_ENABLED --> 0).

When DEBUGGER_ENABLED    1, everything works fine but as i need lower power consumption i want to deactivate it.

In an5406 it mentions that "The debug mode enables the SWD pins, even when the MCU goes in low-power mode."

however, neither PB8 nor DMA has anything to do with the serial-wire-debugging feature.

I'm trying to understand how to shut the debugger without interrupting the Functionality.

 

AElgh
AElghAuthor
Associate III
July 3, 2024

In AN5406 Page 30 (9.3 Low-power functions), it mentioned "when the DMA is used to
print data to the console, the system must not enter a low-power mode below Sleep mode because the DMA
clock is switched off in Stop mode"

I put this code just before it entered the Stop-Mode2 Sleep but it doesn't seem to succeed:

void UTIL_SEQ_Idle(void)
{
	/* USER CODE BEGIN UTIL_SEQ_Idle_1 */

	if(!__HAL_RCC_DMA2_IS_CLK_SLEEP_ENABLED())
	{
		APP_LOG(TS_OFF, VLEVEL_M, "DMA2 Clock is not Enabled in Deep-Sleep\r\n\n");
		__HAL_RCC_DMA2_CLK_SLEEP_ENABLE();
	}
	HAL_SuspendTick();
	/* USER CODE END UTIL_SEQ_Idle_1 */
	UTIL_LPM_EnterLowPower();
	/* USER CODE BEGIN UTIL_SEQ_Idle_2 */
	HAL_ResumeTick();

	/* USER CODE END UTIL_SEQ_Idle_2 */
}

 

I still get the "HAL_TIM_PWM_Start_DMA Error" 

 

Any suggestion is appreciated.