Bug in X-CUBE-PWM-DITHR
In the X-CUBE-PWM-DITHR example application, which is supposed to accompany AN4507, PWM dithering is demonstrated by TIM1_CCR1 modified using timer-update-triggered circular DMA from an array of values, which is in turn generated in the DMA half-complete and complete interrupts.
While the array is supposed to contain 16 values, and the two interrupts update 8 and 8 values accordingly; the DMA itself is started (in TIM1_PWM_UPDATE_DMA()) by calling HAL_DMA_Start_IT() with parameter Length set to 8, which is probably a bug.
It wouldn't help to just simply change this value to 16, as the DMA source buffer is defined as
uint32_t aDitherTable[16];
but DMA is set to read halfwords, and the interrupts updating the values acess this array through following macros
#define DITHER_TABLE_FIRST_PART ((uint16_t*) aDitherTable)
#define DITHER_TABLE_SECOND_PART ((uint16_t*)(aDitherTable + 8))
i.e. the second 8 halfwords are updated in aDitherTable[8..11] whereas the DMA, would it be set to transfer 16 halfwords, would read them from aDitherTable[0..7].
I don't Cube so I might've overlooked something.
This bug has been originally reported by a user in a local hw-related mailing list.
JW
PS. There is no appropriate tag ("Topic") for appnotes and software examples.
