cancel
Showing results for 
Search instead for 
Did you mean: 

Hard fault with DMA on TIM3_CH2 (but on TIM1_CH1) for WS2812B LEDs

rubinstu
Associate

Hard fault with DMA on TIM3_CH2 (but on TIM1_CH1) for WS2812B LEDs


I am trying to control WS2812 addressable LEDs. This example (Interface WS2812 with STM32) works great using TIM1_CH1 to generate a PWM signal on output PA8. It uses DMA to adjust he duty cycle after each pulse to flip between the logical "on" and "off" signal for each color of each LED. (DMA request TIM1_CH1, DMA1 Channel 2.)

In my actual hardware, I need to drive the LEDs using PA7. This is done using TIM3_CH2. I modified the example in the link to use TIM3_CH2. This uses DMA request TIM3_CH4/up, DMA1 channel 3. There are no other changes. Unfortunately, I get a hard fault using the new configuration.

Processor is STM32103C8T6. I am using the STM32CubeIDE to setup the the hardware, timers, DMA, etc.

The code changes, in addition to the configuration changes in the STM32Cube .ioc and the generated configuration code are:

From:

HAL_TIM_PWM_Stop_DMA(&htim1, TIM_CHANNEL_1);
to:

HAL_TIM_PWM_Stop_DMA(&htim3, TIM_CHANNEL_2);

and

HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)pwmData, indx);

to:

HAL_TIM_PWM_Start_DMA(&htim3, TIM_CHANNEL_2, (uint32_t *)pwmData, indx);

Any ideas on why I'm getting a hard fault here?

Thank you!

2 REPLIES 2

Investigate further details about your hard fault, may be there you can find informations:
https://developer.arm.com/documentation/dui0552/a/cortex-m3-peripherals/system-control-block/hardfault-status-register

BTW: You can use MOSI (SPI) output to generate bitstream for WS2812 and reduce RAM footprint and DMA traffic.

nimaltd
Senior

you can use my pack. 

https://github.com/nimaltd/ws28xx

please watch the video how to install and use.