2021-05-14 06:05 AM
So I'm trying to control 8 different PWM signals simultaneously using DMA (Nucleo-F429ZI connected with 8 lines of SK6812 LEDs).
So save memory space I implemented the strategy described in this blog to save memory. Basically using half-transfer and full-transfer interrupts to fill up the PWM data for the next LED.
However I'm running into some issues due to the interrupt routine not being able to execute fast enough when I try to scale this approach to 4 different PWM signals (with the goal of 8 eventually).
A picture says a thousand words:
Picture 1
D5 -> TIM3-CH4 -> DMA1_Stream2
D6 -> TIM3-CH3 -> DMA1_Stream7
D7 -> TIM3-CH2 -> DMA1_Stream5
D8 -> TIM3-CH1 -> DMA1_Stream4
D15 -> Toggles for each interrupt routine of TIM3-CH3
As you can see CH3 is lowest priority so it routinely gets interrupted during its execution and only at the end is able to 'catch' up so to speak. (However I'd like for them to work simultaneously!)
Picture 2
If I disable one channel (TIM3-CH4 for example) this behavior disappears. (D5 is disabled, ignore the noisy parts)
Pictures 3 and 4 all the most relevant parts of the interrupt routine.
Can anyone give some pointers as to how I could speed up the execution of my interrupt routine? (preferably without impacting memory usage too much)
I already tried cutting out some parts of the HAL interrupt functions (which helped some, but not enough).
Is this the point where assembly programming gets into the picture? (don't have any experience with this yet)
My code can be found: https://github.com/maksimdrachov/F429-SK6812
2021-05-14 11:51 AM
> Can anyone give some pointers as to how I could speed up the execution of my interrupt routine?
Switching on compiler optimization?
Splitting Set_InitPwm() to N explicit functions for the individual channels, so that in the very inner loop there's no branching?
JW
2021-05-15 12:13 PM
Drop HAL ISR processing completely and implement your own minimal one. That way you will avoid a bunch of overhead calls, tests and save both FLASH and RAM.