cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 GPDMA getting remaining bytes when using linked lists

miladmohtashamirad
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
miladmohtashamirad
Associate II

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.1
ST Employee

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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.