OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 4819|回复: 1

用DMA1控制USART1发送数据,通道1能发送成功,通道4反而不能

[复制链接]

4

主题

15

帖子

0

精华

初级会员

Rank: 2

积分
51
金钱
51
注册时间
2014-4-26
在线时间
0 小时
发表于 2014-7-6 01:27:12 | 显示全部楼层 |阅读模式
5金钱
彻底凌乱,大概没人遇过这种诡异的问题吧==!
[mw_shl_code=c,true] #include "stm32f10x.h" #include "stm32f10x_conf.h" #include "misc.h" #include "usart.h" #include "sys.h" GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; vu8 USARTOutVal[5]="hello"; void DMA_Configuration(void); void RCC_Configuration(void); void GPIO_Configuration(void); int main(void) { RCC_Configuration(); GPIO_Configuration(); DMA_Configuration(); delay_init(); uart_init(115200); while(1); } void GPIO_Configuration(void) { GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); } void RCC_Configuration(void) { SystemInit(); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB , ENABLE); } void USART_Config(USART_TypeDef* USARTx) { USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USARTx, &USART_InitStructure); USART_ITConfig(USARTx, USART_IT_RXNE, ENABLE); USART_ITConfig(USARTx, USART_IT_TXE, ENABLE); USART1->CR3=1<<7; USART_Cmd(USARTx, ENABLE); } void DMA_Configuration(void) { DMA_InitTypeDef DMA_InitStructure; /* Enable DMA clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); /* DMA channel1 configuration ----------------------------------------------*/ //使能DMA DMA_DeInit(DMA1_Channel1); //DMA通道1的地址 DMA_InitStructure.DMA_PeripheralBaseAddr = 0x40013804; DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&USARTOutVal; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = 5; //传送内存大小,100个16位 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //传送内存地址递增 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //循环 DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel1, &DMA_InitStructure); //使能DMA通道1 DMA_Cmd(DMA1_Channel1, ENABLE); } [/mw_shl_code]

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2014-7-7 00:08:09 | 显示全部楼层
设置问题吧,参考下我们的代码。
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-7-6 13:28

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表