I'm trying to use a DMA interrupt to indicate that new data is available from the DCMI interface which is connected to a camera.

The buffer content of the DMA (an image) is then used in the main-loop for sending the image data to the display. The Display writing and transfer is quiete slow and so it happens that a new picture is ready when the old picture is not fully written to the display, and the writing of images overlaps.

I have read about the consumer-producer/buffer queue/circular buffer but not sure I understand how to implement it.

One of my problems why I'm not able to implement the buffer queue (with head and tail) is because the DMA writes the whole dataset to the array, not every pixel can be monitored when written. On the other hand the Image (saved in an array) is read pixel by pixel.

Here an exmaple of code:

void DMA_IRQ(void)
{
    if (DMA_Full && DMA_Enabled)
    {
        DMA->CLEARFLAG = CLEAR; //Clear Interrupt Flag

        //Now in the Background the variable
        //dma_frame_buffer is filled with read data of the DMA

        //DMA Indicator
        dma_frame_read = 1;
    }
}

In my main looks something like this:

int main (void)
{
    if(dma_frame_read == 1)
    {
    for(int pixel_counter=0; pixel_counter<253; pixel_counter++)
    {
          ILI9341_Color_Send(dma_frame_buffer[pixel_counter]);
      dma_frame_read = 0;
    }
}

0 Answers