你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

DMA中的USART串口发送的问题,不知道是不是bug

[复制链接]
电小龙 提问时间:2016-10-11 15:54 /
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]的数据。请问这是为什么呢?
收藏 评论4 发布时间:2016-10-11 15:54

举报

4个回答
nashchen17 回答时间:2016-10-18 12:31:38
我也遇到類似問題,使用Normal丟了一次後就不再丟了
adlu 回答时间:2016-10-18 14:29:46
在中断里面写
HAL_UART_DMAStop(&huart1);
HAL_UART_DMAResume(&huart1);
试一试

评分

参与人数 1ST金币 +2 收起 理由
zero99 + 2

查看全部评分

adlu 回答时间:2016-10-18 14:42:56
或者在每次发送前查询UART的状态
while (HAL_UART_GetState(&huart1) != HAL_UART_STATE_READY);
xmshao 回答时间:2016-10-18 15:30:35
本帖最后由 xmshao 于 2016-10-20 08:43 编辑

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);可能没有生效。

评分

参与人数 1ST金币 +2 收起 理由
zero99 + 2

查看全部评分

所属标签

相似问题

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版