Question
HAL_UART_Receive_DMA() not able to receive data in the array or in the SRAM
Hi,
I'm trying to receive data from UART peripheral to DMA using HAL Library. I'm using STM32F410RB.
I tried all the possible configuration as in reference manual -

Code part -
//#define OFFSET 0x800
//#define DEST_ADDR (SRAM1_BASE + OFFSET) //Tried writing to SRAM
static void MX_USART2_UART_Init(void)
{
huart2.Instance = USART2;
huart2.Init.BaudRate = 115200; //Tried with other Baud rates
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
}
static void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE();
/* DMA interrupt init */
/* DMA1_Stream7_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream7_IRQn, 0, 0); //Tried Stream5 as in RM
HAL_NVIC_EnableIRQ(DMA1_Stream7_IRQn);
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
UNUSED(huart);
}
int main(void)
{
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_DMA_Init();
while (1)
{
uint8_t data[255]={0};
HAL_UART_Receive_DMA(&huart2, data, 255);
}
}
Terminal setting -

