cancel
Showing results for 
Search instead for 
Did you mean: 

How To Use the HMDMA device in Address Decrement Mode.

Garnett.Robert
Senior III

I wish to use MDMA to push a two dimensional FFT complex FIFO array in the AXI Memory, using MDMA.

I have an array of 256 * 128 complex floating point numbers, and wish to copy the first 127 columns over the last 127 columns to make room for the next fft. i.e. FIFO.

So I don't write over the data I being moved I have to start copying from the end of the array i.e the last columns and work backwards. To do this I tried using MDMA decrement the address rather than increment.

I have a couple of questions relating to this.

1. Do I set the source and destination addresses for the transfer at the start and start + 1 of the buffer or should I set them at the end. It is not clear, (as usual) in the documentation whether the address gets decremented down from what you put in the registers or whether the MDMA device sets the address at the register address + the byte count register and then decrements from that value, or whether it simply starts at the register address and then decrements from this. In the second case you would have to load the ending address values of the array rather than the start.

2. How do I set up the device using HAL to do this copy within the AXI memory. Must I use doubleword, and what block sized should I set.

I got the MDMA working copying a 256 floating point complex array from the DTCM mamory into the AXI without any problems, but I can't seem to get it working within the AXI memory alone.

I wish to copy the data under interrupts as fast as possible. I am using interrupts as I do the FFT preprocessing and the FFT's in parallel with the FIFO buffer push.

Using the caches and compiler optimization I can do all the DSP in about 12 ms, but the AXI -MDMA thin has me stumped.

RJG

1 REPLY 1
Garnett.Robert
Senior III

I figured it out.

Q1. The source and destination addresses are the start (low end address of the array).

Q2. I was trying to send more than 65 k of data. I fixed the problem by sending 127 blocks of 2048 bytes. It does this in around 470 us with a HCLK of 400 MHz. It could probably be done faster by having larger blocks, but with an odd no of blocks this was messy and 470us is way fast enough.

/*************************** PUSH THE 2D ARRAY FIFO ****************************************/
HAL_StatusTypeDef pushFFT2dFIFO(void)
{
	/* Create pointers into the fft structures for the block transfer */
	fft2D_Src_ptr = &fft2D_U.cIn[NO_CHIRPS - 2][FFT_SIZE - 1];
	fft2D_Dst_ptr = &fft2D_U.cIn[NO_CHIRPS - 1][FFT_SIZE - 1];
	
/**
  * @brief  Starts the MDMA Transfer.
  * @param  hmdma           : pointer to a MDMA_HandleTypeDef structure that contains
  *                           the configuration information for the specified MDMA Stream.  
  * @param  SrcAddress      : The source memory Buffer address
  * @param  DstAddress      : The destination memory Buffer address
  * @param  BlockDataLength : The length of a block transfer in bytes
  * @param  BlockCount      : The number of a blocks to be transfer
  * @retval HAL status
  */
	mdmaCh_1_Complete = MDMA_PENDING;
	if(HAL_MDMA_Start_IT(&hmdma_mdma_channel1_sw_0, (uint32_t)fft2D_Src_ptr, 
											(uint32_t)fft2D_Dst_ptr, FFT_SIZE * 4 * 2, (NO_CHIRPS - 1))	!= HAL_OK)
	{
		return HAL_ERROR;
	}	
	return HAL_OK;
}