cancel
Showing results for 
Search instead for 
Did you mean: 

Help with 90 degree rotation of image with MDMA linked-list

I've successfully modified the MDMA_RepeatBlock_Rotation example for the stm32h735g-dk to do 90 degree rotation (main_repeat_block.c). Now I want to use linked-list mode.

The way I implemented it currently is to use repeated block transfer to transfer one line from source to a destination column. Then I repeat this transfer for every line, but shifted by one pixel. Since the source and destination increment/decrement only supports 1,2,4 and 8 bytes I use a block size of 1 pixel and use display height as the number of blocks. Every block will have an offset equal to the width of the screen so it shifts to the next line. Since the screen and source image is not square I had to implement some offsets.

The only disadvantage of this method is that it requires calling the transfer for every row, so 272 transfers in my case. I could do this in an interrupt but I prefer a 100% DMA solution since I don't want many thousands of interrupts per second.

If I can use 272 nodes in a linked list then I can rotate everything in hardware without interrupts in between. If there is a limit in the number of nodes, then it should at least reduce the number of interrupts.

Here is some code:

 

int i;
for(i=0;i<272;++i)
{
	MDMA_Config(config);
	
	mdma_Destination_address = LCD_FRAME_BUFFER + ( 480*(272-1) + (480-272)/2 + i)*RGB565_BYTES_PER_PIXEL;
	mdma_Source_address = (uint32_t)&RGB565_480x272 + ((480-272)/2+i*480)*RGB565_BYTES_PER_PIXEL;
	
	TransferCompleteDetected = 0;
	TransferErrorDetected = 0;
	hal_status = HAL_MDMA_Start_IT(&MDMA_Handle, mdma_Source_address,
											   mdma_Destination_address,
											   1 * RGB565_BYTES_PER_PIXEL,
											   272);


	while((TransferCompleteDetected == 0) && (TransferErrorDetected == 0)) {}
}

 

 

And in the MDMA_Config() this is the most important line:

 

MDMA_Handle.Init.DestBlockAddressOffset = (-480-1)*RGB565_BYTES_PER_PIXEL;

 

 

Now if I implement this in this with linked list mode only node 0 works (the implicit node). Then the interrupt never fires.

I've created a simplified example based on the MDMA_LinkedList example. This only uses a small 4x4 array and no display. I've attached the modified main file (main.c). The first source row is successfully transferred to the destination column, but the created nodes node1 and node2 don't seem to do anything and no interrupt is fired. I don't know why it's not working.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
0 REPLIES 0