cnlohr / ch32v003fun

An open source software development stack for the CH32V003 10¢ 48 MHz RISC-V Microcontroller - as well as many other chips within the ch32v/x line.
MIT License
822 stars 126 forks source link

DMA interrupts mixed up in WS2812B driver #207

Closed dquadros closed 11 months ago

dquadros commented 11 months ago

In the DMA IRQ handler, Transmission Complete and Halfway Empty tests are switched:

if( intfr & DMA1_IT_TC3 )
{
    // Halfwaay (Fill in first part)
    WS2812FillBuffSec( WS2812dmabuff, DMA_BUFFER_LEN / 2, 1 );
}
if( intfr & DMA1_IT_HT3 )
{
    // Complete (Fill in second part)
    WS2812FillBuffSec( WS2812dmabuff + DMA_BUFFER_LEN / 2, DMA_BUFFER_LEN / 2, 0 );
}

It should be

if( intfr & DMA1_IT_HT3 )
{
    // Halfwaay (Fill in first part)
    WS2812FillBuffSec( WS2812dmabuff, DMA_BUFFER_LEN / 2, 1 );
}
if( intfr & DMA1_IT_TC3 )
{
    // Complete (Fill in second part)
    WS2812FillBuffSec( WS2812dmabuff + DMA_BUFFER_LEN / 2, DMA_BUFFER_LEN / 2, 0 );
}
cnlohr commented 11 months ago

I believe you are right but it makes things not work on my board. Does flipping them work for you?

dquadros commented 11 months ago

Yes it worked. I have to find the code and clean it up, but you can see (briefly) my demo here: https://youtu.be/UYo61C7A4T4?t=306

cnlohr commented 11 months ago

Understood. I tested and it worked fine. Fixed in 3bd7770