Dear Cifron,
I’m sorry for the late reply and letting you working on this matter for weeks.
I’m using the APM32F0xx_SDK_V1.8.4 as the standard peripheral library, within the SDK you can find the example “DMA\DMA_Usart”, the USART1 initiation (which is configured before DMA1_CH4_5 enabling and NVIC configuration) includes using SYSCFG on APB2 to remap the DMA channel.
Please find the codes below:
From USART1_Init()
/* Enable SYSCFG Clock for Remaping DMA Channel*/
RCM_EnableAPB2PeriphClock(RCM_APB2_PERIPH_SYSCFG);
/* Remap USART1_RX Channel to DMA channel 5*/
SYSCFG_EnableDMAChannelRemap(SYSCFG_DAM_REMAP_USART1RX);
From DMA_RX_Init(), the initiation of DMA_TX shall be similar
/* Enable DMA clock */
RCM_EnableAHBPeriphClock(RCM_AHB_PERIPH_DMA1);
/* DMA Configure */
DMA_Config_T dmaConfig;
/* size of buffer*/
dmaConfig.bufferSize = BufSize;
/* set memory Data Size*/
dmaConfig.memoryDataSize = DMA_MEMORY_DATASIZE_BYTE;
/* Set peripheral Data Size*/
dmaConfig.peripheralDataSize = DMA_PERIPHERAL_DATASIZE_BYTE;
/* Enable Memory Address increase*/
dmaConfig.memoryInc = DMA_MEMORY_INC_ENABLE;
/* Disable Peripheral Address increase*/
dmaConfig.peripheralInc = DMA_PERIPHERAL_INC_DISABLE;
/* Reset Circular Mode*/
dmaConfig.circular = DMA_CIRCULAR_DISABLE;
/* Disable M2M*/
dmaConfig.memoryTomemory = DMA_M2M_DISABLE;
/* set priority*/
dmaConfig.priority = DMA_PRIORITY_LEVEL_HIGHT;
/* read from memory*/
dmaConfig.direction = DMA_DIR_PERIPHERAL;
/* Set memory Address*/
dmaConfig.memoryAddress = (uint32_t)RxBuf;
/* Set Peripheral Address*/
dmaConfig.peripheralAddress = (uint32_t)&USART1->RXDATA;
DMA_Config(DMA1_CHANNEL_5, &dmaConfig);
/* Clear DMA TF flag*/
DMA_ClearIntFlag(DMA1_INT_FLAG_TF5);
/* Enable DMA Interrupt*/
DMA_EnableInterrupt(DMA1_CHANNEL_5, DMA_INT_TFIE);
#if defined (APM32F030)
NVIC_EnableIRQRequest(DMA1_CH4_5_IRQn, 2);
USART_ClearStatusFlag(USART1, USART_FLAG_TXC);
DMA_Enable(DMA1_CHANNEL_5);
From DMA_Isr() //The playback function of DMA1_CH4_5_IRQHandler()
if (DMA_ReadStatusFlag(DMA1_FLAG_TF5))
{
/* do something*/
DMA_ClearStatusFlag(DMA1_FLAG_TF5);
}
From main()
USART1_Init();
/* Config channel5 of DMA */
DMA_Disable(DMA1_CHANNEL_5);
DMA_Rx_Init((uint32_t*)DMA_USART_RxBuf);
USART_EnableDMA(USART1, USART_DMA_REQUEST_RX);
The function SYSCFG_EnableDMAChannelRemap() requires parameter as uint32_t channel: SYSCFG_DAM_REMAP_USART1TX, SYSCFG_DAM_REMAP_USART1RX.
Here’s the introduction to the registers that are related to the remap of DMA channels:


