Skip to main content
Explorer II
May 27, 2024
Solved

STM32U5 GPDMA getting remaining bytes when using linked lists

  • May 27, 2024
  • 2 replies
  • 1946 views

Hi. 
I'm using STM32U585 with OV5640 to capture the image. I set the DMCI synchronization to hardware to us Hsync and Vsync. However, I set the camera to send JPEG image rather than raw image, so the frame size is unknown. Now the problem is that it's not possible to use the frame_event to capture an frame. because the way I see frame_event, it's fired when the buffer size that we specified when we start capture is filled. which might contain several and half image. So, I have to use Vsync_event. What I can't find out is how to know how many bytes has been transferred when the Vsync_event has happened. The dcmi is using linked list dma. 
My question is:
How can I read how many bytes has been transferred by the DMA? where should I look at?

Kind Regards,
Milad

    This topic has been closed for replies.
    Best answer by KDJEM.1

    Hello @miladmohtashamirad ,

    Also, you can know the block number of data bytes to transfer from the source using GPDMA_CxBR1 register and BNDT[15:0] bits: block number of data bytes to transfer from the source.

    Block size transferred from the source. When the channel is enabled, this field becomes read-only and is decremented, indicating the remaining number of data items in the current source block to be transferred. BNDT[15:0] is programmed in number of bytes, maximum source block size is 64 Kbytes -1.

    For more information, I advise you to refer to RM0456 precisely section 17.8 GPDMA registers.

    Also may AN5020 can help you to start with DCMI.

    Thank you.

    Kaouthar

    2 replies

    Explorer II
    May 27, 2024

    I think I found a way. But I'm not sure if it's the best way to do so.
    I'm reading the CDAR register (hdcmi.DMA_Handle->Instance->CDAR). Assuming that it's pointing to next byte location, I can calculate the already transferred bytes by subtracting the first byte address from it. 

    KDJEM.1Answer
    Technical Moderator
    May 27, 2024

    Hello @miladmohtashamirad ,

    Also, you can know the block number of data bytes to transfer from the source using GPDMA_CxBR1 register and BNDT[15:0] bits: block number of data bytes to transfer from the source.

    Block size transferred from the source. When the channel is enabled, this field becomes read-only and is decremented, indicating the remaining number of data items in the current source block to be transferred. BNDT[15:0] is programmed in number of bytes, maximum source block size is 64 Kbytes -1.

    For more information, I advise you to refer to RM0456 precisely section 17.8 GPDMA registers.

    Also may AN5020 can help you to start with DCMI.

    Thank you.

    Kaouthar

    Explorer II
    May 27, 2024

    Thanks @KDJEM.1 .
    True. GPDMA_CxBR1[0:15] shows the remaining bytes. 
    So far, there are two ways to see where the DMA is at a certain point:
    hdcmi.DMA_Handle->Instance->CBR1 & 0x0000FFFF   : tells how many more bytes remains to be transferred.
    hdcmi.DMA_Handle->Instance->CDAR   :  tells where the next byte is going to be.