Skip to main content
This topic has been closed for replies.

2 replies

Uwe Bonnes
Chief
May 24, 2019

Check that DMA memory areas fit with the DMA capabilities. Check you code carefully. Deciper error codes for failing code. As soon as you do it right, it will work :)

gcaif
gcaifAuthor
Associate II
May 24, 2019

/*###ICF### Section handled by ICF editor, don't touch! ****/

/*-Editor annotation file-*/

/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */

/*-Specials-*/

define symbol __ICFEDIT_intvec_start__ = 0x08000000;

/*-Memory Regions-*/

define symbol __ICFEDIT_region_ROM_start__  = 0x08000000;

define symbol __ICFEDIT_region_ROM_end__   = 0x081FFFFF;

define symbol __ICFEDIT_region_RAM_start__  = 0x20000000;

define symbol __ICFEDIT_region_RAM_end__   = 0x2007FFFF;

define symbol __ICFEDIT_region_ITCMRAM_start__ = 0x00000000;

define symbol __ICFEDIT_region_ITCMRAM_end__ = 0x0000FFFF;

/*-Sizes-*/

define symbol __ICFEDIT_size_cstack__ = 0x400;

define symbol __ICFEDIT_size_heap__ = 0x200;

/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;

define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];

define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];

define region ITCMRAM_region = mem:[from __ICFEDIT_region_ITCMRAM_start__ to __ICFEDIT_region_ITCMRAM_end__];

define region D2_SRAM2_region = mem:[from 0x24000000 to 0x2401FFFF];

define block CSTACK  with alignment = 8, size = __ICFEDIT_size_cstack__ { };

define block HEAP   with alignment = 8, size = __ICFEDIT_size_heap__  { };

initialize by copy { section .dma_buffer}; /* optional initialization of default values */

initialize by copy { readwrite };

do not initialize { section .noinit };

place in D2_SRAM2_region { section .dma_buffer};

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

place in ROM_region { readonly };

place in RAM_region { readwrite,

            block CSTACK, block HEAP };

the above code is my stm32h743xx_flash.icf file.

My code Tx buffer address is 0x24000000 and the Rx buffer is 0x24000008.

my test code:

DMA_BUFFER uint8_t Tx[5] = {1,5,7,8,4};

DMA_BUFFER uint8_t Rx[5];

/* USER CODE BEGIN Header_StartDefaultTask */

/**

 * @brief Function implementing the defaultTask thread.

 * @param argument: Not used 

 * @retval None

 */

/* USER CODE END Header_StartDefaultTask */

void StartDefaultTask(void const * argument)

{

 /* init code for LWIP */

// MX_LWIP_Init();

 SCB_CleanDCache_by_Addr((uint32_t*)(((uint32_t)Rx) & ~(uint32_t)0x1F), 5+32);

 /* USER CODE BEGIN 5 */

 /* Infinite loop */

 for(;;)

 {

  HAL_UART_Receive_DMA(&huart6, Rx, 5);

  if(Rx[0] == 4){

   SCB_CleanDCache_by_Addr((uint32_t*)(((uint32_t)Tx) & ~(uint32_t)0x1F), 5+32);

   HAL_UART_Transmit_DMA(&huart6, Tx, 5);

  }

   

  osDelay(500);

 }

 /* USER CODE END 5 */ 

}