2020-10-26 12:21 AM
Hi I'm using STM32cubeIDE and I use two DMA channels,
DMA1_Channel1 is for ADC1 and DAM1_Channel5 is for USART1_rx.
USART1 is using for RS485 communication.
HAL_ADC_Start_DMA(&hadc1, &adcVal[0], 8);
HAL_UART_Receive_DMA(&huart1, &rxBuffer[0], DMA_RX_BUF_SIZE);
I used these two code to get the value from the communication and analogue date.
I can get the analogue value but I got the wrong value in communication.
static void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE();
/* DMA interrupt init */
/* DMA1_Channel1_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
/* DMA1_Channel5_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
}
There are no priority set, and I heard that I have to configure the DMA channel and
according to the DMA channel I should have to save the value to that buffer.
How could I configure the channel and save the proper value to the adc_buffer and rx_buffer?
2020-10-26 06:59 AM
> I can get the analogue value but I got the wrong value in communication.
If the DMA is saving any values, the problem is likely not with the DMA, but with the peripheral.
In what way are the ADC values incorrect? Maybe you're saying these are correct.
In what way are the UART value incorrect? Does it work in blocking mode? Likely a timing issue is to blame here.
> There are no priority set,
Priority is set to 0 in both.