cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Nucleo board TIM1 stays high after DMA is finished

DAbdi.1
Associate II

I'm using DMA with TIM1 to drive a string of WS2812B LEDs. I am closely following a tutorial called Controlling Neopixels with STM32 on Digikey (I cannot add links due to the age of my account) with some adjustments, with my ARR being 89, my clock being 72MHz, and my code is adjusted to reflect these changes. All of the LEDs in the chain work correctly, except for the first one. The first one is acting as a "passthrough", where all changes I make to it are sent to the next one in sequence and it remains off. For example, when I change LED[0] to fully red, LED[1] receives that change instead and LED[0] remains off. I can confirm that LED[0] is fully functional, as when I connect an Arduino instead of the STM32 the entire chain works perfectly.

 

Using a logic analyzer and looking at the signal, I can see that unlike with the Arduino, the STM32 keeps the pin responsible for the timer high after the DMA is finished, most likely causing the first LED in the sequence to think it's getting a signal and causing it to pass through all data it receives. I have tried activating pull-downs in STM32CUBEIDE, setting the PWM to mode 2, changing the PWM polarity, the PWM idle state, writing the GPIO pin low manually, and some other settings that I do not entirely remember. Unfortunately I cannot get the line to stay low after the DMA is finished. I've attached an image of what I am seeing on the logic analyzer vs what is expected (done with Arduino). How can I set the MCU to set this line low when it's finished transmitting?

 

Apologies for any formatting issues or anything. I am quite new to STM32 and embedded systems in general. Please let me know what I can change to set this line low after the DMA is finished.

 

Thank you


_legacyfs_online_stmicro_images_0693W00000binXoQAI.png

^STM32 signal, please note how the signal remains high after completion.

0693W00000binZQQAY_image.png

^Arduino signal

13 REPLIES 13

In attachment a short program for Nucleo-F411 which generates the following waveform on PA8 after reset (timescale is 1ms/div):


_legacyfs_online_stmicro_images_0693W00000biuneQAA.png 

I know it's not for Cube/HAL, sorry, I don't use Cube.

JW

Kamil Duljas
Senior III

Try add to your data array that you send through DMA "Zero" as the last element, something looks like this:

uint8_t test[] = { 100, 0, 100, 0, 100, 0 };


_legacyfs_online_stmicro_images_0693W00000biwLIQAY.png

Dudo

I have already added this 0 at the end as in the tutorial in the OP. Adding more 0s increases the low time at the end, but once the DMA is finished it returns to being high

DAbdi.1
Associate II

Just wanted to give an update on here in case anybody was encountering the same issues as me. Changing from TIM1 Channel 1 to TIM1 Channel 2 fixed my problem. I do not know why. The board and its wires are close to a spark gap so maybe that damaged something and caused the issue? I have absolutely no idea. It was working beforehand and I changed nothing in the configuration to cause this issue (Or anything at all really, I was well past the configuration stage when the issue popped up). Changing the pin itself to GPIO and setting it low did not change the pin either, so I'm inclined to believe there's some damage somewhere (A visual inspection of the board reveals no obvious damage). Regardless, if anyone else comes across this having an issue, try and change to a different pin on your board. Thank you to everyone for the help with this.