
HAL_UART_Transmit_DMA这个函数在使用了进行一次后,好像再使用时就不会根据最新的一次设置来改变了。比我我下面的代码这样 HAL_UART_Transmit_DMA(&huart1, DataBuff, 10);这个函数为第一次的设置,然后就开启的循环发送,开启DMA中断。 HAL_UART_DMAPause(&huart1);在中断里面暂停。 延时2秒后,再 HAL_UART_Transmit_DMA(&huart1, &DataBuff[5], 5); HAL_UART_DMAResume(&huart1); 我想要的目的是第一次串口发送的数值是DataBuff[0]至DataBuff[9]的数据到串口助手上去,第二次发送的是DataBuff[5]至DataBuff[9]到串口助手上去。但是结果是第一次和第二次都是一样的,发送的都是DataBuff[0]至DataBuff[9]的数据。请问这是为什么呢? |
HAL_UART_DMAStop(&huart1);
HAL_UART_DMAResume(&huart1);
试一试
评分
查看全部评分
while (HAL_UART_GetState(&huart1) != HAL_UART_STATE_READY);
The following sequence should be followed to configure a DMA stream x (where x is the
stream number):
1. If the stream is enabled, disable it by resetting the EN bit in the DMA_SxCR register,
then read this bit in order to confirm that there is no ongoing stream operation. Writing
this bit to 0 is not immediately effective since it is actually written to 0 once all the
current transfers have finished. When the EN bit is read as 0, this means that the
stream is ready to be configured. It is therefore necessary to wait for the EN bit to be
cleared before starting any stream configuration
也就是说HAL_UART_Transmit_DMA(&huart1, &DataBuff[5], 5);可能没有生效。
评分
查看全部评分