It’s strange to see, that there is no discussions about DMA of stm32 in Spark Core.
I’m trying to make adaptation of library wich using DMA on stm32f4…
And there’s strange thing: it’s stuck on NVIC init. Here is my code of initialisation:
Hi BDub, you will also be interested, as i think
I’m trying to combine https://github.com/x893/stm-ledstrip/ and https://github.com/Torrentula/STM32F1-workarea/tree/master/Project/WS2812 with rewriting in c++
I’ve already reviewed my code and changed: pin to PB6(D1) timer to TIM4 channel 1.
Now it’s running, but not sending any of pwm to PB6, and also didn’t calling DMA1_Channel6_IRQHandler function…
Fund thata IRQ callbacks must be defined with extern “C”, still didn’t checked, because found a bug in my websockets port and trying to fix it
Checked this working.
NVIC initializes ok without failings, MCU walks thru code ok, not reboots(it’s really connected to node,js and answers), but there is still no callback on:
Aha… very nice. This seems like a decent way to get accurate timing for the NeoPixels… certainly a very efficient way using DMA.
You have quite a few issues to solve if you have already worked in websockets into the equation.
I would suggest hard coding your prescaler to 0, and bump up your period value to compensate for the change. This will give you more resolution in your PWM duty cycle, and ultimately more accuracy on the various timing of WS2812, WS2812B and WS2811, etc…
Definitely an involved setup, and I wish you luck! Please keep us updated on your progress
That's I tried to say in NeoPixel topic, but my message was totally ignored
Prescaler and other feautures i will tune with oscilloscope, now i want just to send array to pin, but it doesn't want to do this.
Did you even tried to use DMA on STM's? I think that there is some mistake in my code, and hope someone can review it and correct me. This is last edition of code initiating TIM, PB6 and DMA:
You can see in the RM0008 Reference Manual, “13.3.7 DMA request mapping” (page 272) that the DMA requests from TIM4_CH1 will go to DMA Channel 1 instead of Channel 6., so you should also try changing DMA1_Channel6 to DMA1_Channel1.
Guys, i’ve spent a lot of time in another works. It’s deep update released, firmware changes applied. So now i’m faced problems:
My code worked on previous releases of firmware files for local IDE.
But on last release I’ve got red led blink and reboot(as i see - it’s a “panic mode”). I’ve tried to use previous files, but first of all they’ve dropped my wifi credentials after flashing old bin file on updated core. Then it won’t connect with Spark Core android software. So i’ve entered credentials thru USB and core still won’t connect to cloud(that old bin file contains compiled firmware, which can’t disable cloud connection).
Can somebody tell me, is there any changes on DMA usage from firmware?
This is my code of DMA initialization, which causes panic mode:
I’ve tried to remove NVIC enabling and initialization of buffers in function “init_buffers(size)” it’s doesn’t helped. Looks like using of DMA+TIM4 drive core into panic mode.
So, if anyone have local IDE (or maybe cloud IDE can get library files .cpp and .h) I can send them my full code of running ws2812 leds with DMA, that doesn’t works for me now(but worked before).
Hmm. I was wrong. There is no mistakes in DMA config, and it works fine. Problem in color conversion function. I’ve took this function from stm32f4 DMA ws2811 example… Tried to debug it… system doesn’t print even first “color2pwm”, but all previous records is ok.
Also if i comment “DO” structure, function passes ok,
The do {} while() loop should be executing 8 times with mask starting at 0x80, then 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, masking off single bits of the color argument.
How are you calling it? The first argument is a pointer to a pointer to a uint16_t and therefore somewhat unusual in the Arduino world. It also does *dest += 1; implying it writes 8 locations with either 7 or 17.
So where is buffer assigned? There should be a call to malloc or a statically allocated bit of RAM that the pointer buffer points to. If it is just declared as uint16_t *buffer, that does not allocate any storage for the data.
The code above makes sense since you are writing memory with 8 locations for each of green, red, and blue, hence the (i * 24).
But there is no dynamic moves. I want to call my class function ws2812.init() with parameter int size, to create needed buffers to send data to leds. So, how i can dynamically resize arrays or declare it dynamic?
Without knowing too much about it, I would just make it a class data member since there is only going to be one ws2812 global object, right? If you have trouble with the constructor, just make sure the size is truly compile-time constant. If you need to have global DMA code know where it is, have a method to return a pointer to it, I guess. This breaks OO principles but might be very practical.
You can call malloc on the Spark core, but doing so over and over will surely run you out of memory eventually since the heap management is fairly limited. I try to avoid it.
I need to resize this arrays once at time, just on initialization of work.
My plan is:
Read SD card -> read file with animation -> read config from first line of animation file -> initialize ws2812 object (yes in will be only one) with needed parameters -> show animation from next file contents (prepared chars for putting in array )
Thanks again /went to google for malloc, never used it/