2024-09-15 05:57 PM
Hi there;
I'm extremely new to the world of ST, and trying to get my feet under me with it, coming from a few years' experience developing for esp32 microcontrollers using the esp-idf framework.
I have an Adafruit stm32f405 feather; I understand this isn't the same as a proper ST development board, but I am trying to learn with it nevertheless. The board has an onboard neopixel - out of the box, the board can be plugged into USB and the neopixel begins cycling through colors. I *think* it comes configured with circuitPython, but I am interested in getting it working using ST's tools and workflows, and so I'm trying to figure out how to get that neopixel working in cubeIDE.
Studying the schematic, I can see the neopixel is connected via pin PC0. This is where I'm getting a bit lost - I *think* what I need to do is configure PWM using some timer settings somewhere (?), then connect this pin PC0 to that timer/pwm generator. But it's not clear to me how to do this in the cubeMX/visual configuration side of things.
I can see, when I click on some of the pins in the Pinout & Configuration settings, that some have timer options listed among the available settings. But PC0 does not:
So it's not quite clear to me how to proceed (and, again, I am VERY new to this, so just understanding the relationship between the timers and pins and all the configuration settings has put me in a bit of an overwhelmed state). How was it that this neopixel might have worked initially?
From Adafruit's documentation about the board:
The NeoPixel is connected to pin #8 in Arduino, so just use our NeoPixel library and set it up as a single-LED strand on pin 8.
CircuitPython, the NeoPixel is board.NEOPIXEL and the library for it is here and in the bundle. The NeoPixel is powered by the 3.3V power supply but that hasn't shown to make a big difference in brightness or color. The NeoPixel is not used by the built in STM32 bootloader!
I don't really know what it means for the neopixel "not to be used by the bootloader" though...
Thank you for entertaining this question!
Solved! Go to Solution.
2024-09-17 08:17 AM
For this link: https://github.com/MaJerle/stm32-ws2811-ws2812-ws2812b-ws281x-tim-pwm-dma-timer
Read the readme file:
As you are new in the STM32 world, not easy to explain you all the mechanism. You need to start somewhere. I think you need to start some STM32 courses to understand the environment and tools and how STM32 are working.
I suggest you so start with this wiki: https://wiki.st.com/stm32mcu/wiki/Category:Getting_started_with_STM32_:_STM32_step_by_step
See also this thread.
Hope it helps.
2024-09-16 02:15 AM - edited 2024-09-16 02:15 AM
Hello @sb_st,
@sb_st wrote:
I can see, when I click on some of the pins in the Pinout & Configuration settings, that some have timer options listed among the available settings. But PC0 does not:
So it's not quite clear to me how to proceed (and, again, I am VERY new to this, so just understanding the relationship between the timers and pins and all the configuration settings has put me in a bit of an overwhelmed state).
To check, your first entry point is always the documentation.
Regarding the pinout, you need to refer to the datasheet DS8626 / Table 7. STM32F40xxx pin and ball definitions:
As you can see PC0 doesn't have any TIM alternate function. So I think the Neopixel in your board is managed by GPIO and (maybe) driven by a timer.
As your LEDs have the part number WS2812B, I suggest you to refer to these links:
https://github.com/MaJerle/stm32-ws2811-ws2812-ws2812b-ws281x-tim-pwm-dma-timer
https://community.st.com/t5/power-management/controlling-ws2812b-led-strip-with-stm32/td-p/73747
https://controllerstech.com/interface-ws2812-with-stm32/
Hope it helps.
2024-09-17 04:37 AM
Thanks for the response!
To check, your first entry point is always the documentation.
Agreed, I have read both the datasheet and and skimmed the reference manual. I struggle with these as learning materials in that I don't really know what terms I should be looking for.
In the event that anyone of similar (in)experience comes across this thread, here are some clues I found:
Much of the examples I found online presupposed I am using a Nucleo board, or at least have some amount of control as to which pin I connect a neopixel to. The difficulty in this case is that I do not - the neopixel on the Adafruit Feather board is an SMD component physically wired to PC0, so I don't really have any choice about which pin to use. And this seems to affect what options I have to communicate with the neopixel.
2024-09-17 04:53 AM
@sb_st wrote:
Much of the examples I found online presupposed I am using a Nucleo board, or at least have some amount of control as to which pin I connect a neopixel
NUCLEO or not, it's an STM32 MCU used. So need to adapt the code from any platform (Nucleo or something else) to you specific board, for example need to use PC0 in your case. But in your case you are using stm32f405 on which PC0 is not having any Timer output function. So may be you need to control the timing using a Timer while setting the GPIO.
I've already provided some links. I think, the last link I provided is using TIM2/PWM.
Otherwise you need to contact https://www.adafruit.com/product/4382 to have answer about how they control these LEDs.
I don't have any idea how these LEDs are controlled. I'm trying to provide you some tips.
2024-09-17 07:58 AM - edited 2024-09-17 08:11 AM
Thank you! Your tone suggests I should apologize - it's not my intent to seem ungrateful. I'm reading the links you provide and trying to understand them. Most specifically, it is this thing you say:
But in your case you are using stm32f405 on which PC0 is not having any Timer output function. So may be you need to control the timing using a Timer while setting the GPIO.
This part, I'm sorry, I don't understand. "Use a timer while setting the GPIO". So, looking at this link you provided:
https://controllerstech.com/interface-ws2812-with-stm32/
(this guy's youtube channel is quite helpful, by the way, thanks for pointing me indirectly to that). Anyway, I can see he configures a timer, and I can see he configures DMA (I don't fully understand DMA, am still learning about it; my understanding is that this DMA is 'piping' the value of a variable representing my LED colors to...'a peripheral'. Is this peripheral a GPIO? I can't quite wrap my head around where the DMA is 'going to', and if it's being connected to an arbitrary GPIO, I can't see where that's happening in his code).
This other link you provided:
https://github.com/MaJerle/stm32-ws2811-ws2812-ws2812b-ws281x-tim-pwm-dma-timer
does something that seems similar - it seems to be 'routing memory to a peripheral'...is this peripheral a GPIO? Is that what that means?
It feels like these links you provide are indeed quite helpful, it's just this one part that is not clear to me. Or, to restate: it is not clear to me how to 'connect a timer to an arbitrary GPIO' (I don't know if I'm phrasing this question the right way), if we are saying "PC0 does not have any Timer output function"?
2024-09-17 08:17 AM
For this link: https://github.com/MaJerle/stm32-ws2811-ws2812-ws2812b-ws281x-tim-pwm-dma-timer
Read the readme file:
As you are new in the STM32 world, not easy to explain you all the mechanism. You need to start somewhere. I think you need to start some STM32 courses to understand the environment and tools and how STM32 are working.
I suggest you so start with this wiki: https://wiki.st.com/stm32mcu/wiki/Category:Getting_started_with_STM32_:_STM32_step_by_step
See also this thread.
Hope it helps.
2024-09-17 09:01 AM
Thanks for suggesting I read the read me, very helpful advice and one I hadn’t considered. Thanks also for not being condescending at all to someone new to this development environment.
2024-09-17 09:06 AM - edited 2024-09-17 09:15 AM
You're welcome and we are here to help the professionals as well as beginners :) ..