版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、软件:KeilMDK芯片:STM32F103/STM32F107串口数量:4备注:4个串口均配置为DMA读取/串口1初始化函数void uart1_init(u32 bound) /GPIO端口设置GPIO_InitTypeDef GPIO_InitStructure;USART_InitTypeDef USART_InitStructure;NVIC_InitTypeDef NVIC_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA, ENABLE);/使能USART1,GPIOA时
2、钟USART_DeInit(USART1); /复位串口1/USART1_TX PA.9GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; /PA.9GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;/复用推挽输出GPIO_Init(GPIOA, &GPIO_InitStructure); /初始化PA9/USART1_RX PA.10GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;GP
3、IO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;/浮空输入GPIO_Init(GPIOA, &GPIO_InitStructure); /初始化PA10/Usart1 NVIC 配置NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1 ;/抢占优先级3NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;/子优先级3NVIC_InitStruc
4、ture.NVIC_IRQChannelCmd = ENABLE;/IRQ通道使能NVIC_Init(&NVIC_InitStructure);/根据指定的参数初始化VIC寄存器/*Enable DMA Channel4 Interrupt */NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel4_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;NVIC_InitStruc
5、ture.NVIC_IRQChannelCmd = ENABLE;NVIC_Init(&NVIC_InitStructure);/*Enable DMA Channel5 Interrupt */NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel5_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;NVIC_InitStructure.NVIC_IRQChannelCmd =
6、 ENABLE;NVIC_Init(&NVIC_InitStructure);/USART 参数初始化设置USART_InitStructure.USART_BaudRate = bound;/一般设置为9600;USART_InitStructure.USART_WordLength = USART_WordLength_8b;/字长为8位数据格式USART_InitStructure.USART_StopBits = USART_StopBits_1;/一个停止位USART_InitStructure.USART_Parity = USART_Parity_No;/无奇偶校验位USART_
7、InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;/无硬件数据流控制USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;/收发模式USART_Init(USART1, &USART_InitStructure); /初始化串口/ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);/开启中断USART_ITConfig(USART1, USART_IT_IDLE , ENABLE);/开
8、启空闲中断USART_Cmd(USART1, ENABLE); /使能串口 /串口2初始化函数void uart2_init(u32 bound)GPIO_InitTypeDef GPIO_InitStructure;USART_InitTypeDef USART_InitStructure;NVIC_InitTypeDef NVIC_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);/使能GPIOA时钟RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);/
9、使能USART2时钟GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;/PA2GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;/复用推挽GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(GPIOA, &GPIO_InitStructure);GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;/PA3GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; /浮空输入GP
10、IO_Init(GPIOA, &GPIO_InitStructure); RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2,ENABLE);/复位串口2RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2,DISABLE);/停止复位USART_InitStructure.USART_BaudRate = bound;/一般设置为9600;USART_InitStructure.USART_WordLength = USART_WordLength_8b;/8位数据长度USART_InitStructure.USART
11、_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(USART2, &USART_InitStructure); ; /初始化串口NV
12、IC_InitStructure.NVIC_IRQChannel = USART2_IRQn; /使能串口2中断NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; /先占优先级2级NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; /从优先级2级NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; /使能外部中断通道NVIC_Init(&NVIC_InitStructure); /根据NVIC_InitStruct中指定的参数初始化外设NV
13、IC寄存器/Enable DMA Channel7 Interrupt /NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel7_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;NVIC_Init(&NVIC_InitStructure);/*Enable DMA Channel6
14、Interrupt */NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel6_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;NVIC_Init(&NVIC_InitStructure);/ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE)
15、;/开启中断USART_ITConfig(USART2, USART_IT_IDLE , ENABLE);/开启空闲中断USART_Cmd(USART2, ENABLE); /使能串口 /串口3初始化函数void uart3_init(u32 bound) /GPIO端口设置GPIO_InitTypeDef GPIO_InitStructure;USART_InitTypeDef USART_InitStructure;NVIC_InitTypeDef NVIC_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE)
16、;/使能GPIOB时钟RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE);/使能USART3时钟USART_DeInit(USART3); /复位串口3/USART1_TX PB.10GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; /PB.10GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;/复用推挽输出GPIO_Init(GPIOB, &GPIO_InitSt
17、ructure); /初始化PB.11/USART1_RX PB.11GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;/浮空输入GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(GPIOB, &GPIO_InitStructure); /初始化PB/USART 初始化设置/#ifdef EN_USART3_RX /如果使能了接收USART_InitStructure.USART_Baud
18、Rate = bound;/一般设置为9600;USART_InitStructure.USART_WordLength = USART_WordLength_8b;/字长为8位数据格式USART_InitStructure.USART_StopBits = USART_StopBits_1;/一个停止位USART_InitStructure.USART_Parity = USART_Parity_No;/无奇偶校验位USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;/无硬件数据流控制U
19、SART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;/收发模式USART_Init(USART3, &USART_InitStructure); /初始化串口/Usart1 NVIC 配置NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1;/抢占优先级3NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;/子优先级3NVI
20、C_InitStructure.NVIC_IRQChannelCmd = ENABLE;/IRQ通道使能NVIC_Init(&NVIC_InitStructure);/根据指定的参数初始化VIC寄存器/ /*Enable DMA Channel2 Interrupt */ /NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel2_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1
21、;NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;NVIC_Init(&NVIC_InitStructure);/*Enable DMA Channel3 Interrupt */NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel3_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;NVIC_InitStructure.NVIC_
22、IRQChannelCmd = ENABLE;NVIC_Init(&NVIC_InitStructure);/ USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);/开启中断USART_ITConfig(USART3, USART_IT_IDLE , ENABLE);/开启空闲中断USART_Cmd(USART3, ENABLE); /使能串口 /串口4初始化函数void uart4_init(u32 bound)GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStruct
23、ure;NVIC_InitTypeDef NVIC_InitStructure;DMA_InitTypeDef DMA_InitStructure; /定义DMA初始化结构体DMA_InitStructure /NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); /选择NVIC优先级分组0 RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE); RCC_APB2PeriphClockCmd(RCC_A
24、PB2Periph_GPIOC,ENABLE);/ 打开串口外设的时钟RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);/串口4所使用管脚输出输入定义/定义UART4 Tx (PC.10)脚为复用推挽输出GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; /IO口的第2脚GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /IO口速度GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; /IO口复用推挽输出GPIO_
25、Init(GPIOC, &GPIO_InitStructure); /初始化串口1输出IO口/定义 UART4 Rx (PC.11)为悬空输入 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; /IO口的第3脚GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;/IO口悬空输入GPIO_Init(GPIOC, &GPIO_InitStructure); /初始化串口1输入IO口 /串口4参数初始化定义部分,串口1参数为9600 , 8 ,1 ,N 接收中断方式 USART_InitStructure.US
26、ART_BaudRate = bound; /设定传输速率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;/
27、不用流量控制USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /使用接收和发送功能USART_Init(UART4, &USART_InitStructure); /初始化串口4USART_ITConfig(UART4, USART_IT_IDLE,ENABLE); /使能串口4接收中断USART_Cmd(UART4, ENABLE); /使能串口4USART_ClearFlag(UART4, USART_FLAG_TC); / 清标志(后增加) DMA_DeInit(DMA2_Channel3); /重置DMA 2
28、通道配置DMA_InitStructure.DMA_PeripheralBaseAddr = 0x40004C04; /外设地址 DMA_InitStructure.DMA_MemoryBaseAddr = (u32)USART4_RECEIVE_DATA; /内存地址 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; /外设作为数据目的地 DMA_InitStructure.DMA_BufferSize = 512; /DMA缓存大小:BufferSize DMA_InitStructure.DMA_PeripheralInc = DMA_
29、PeripheralInc_Disable; /外设地址寄存器不递增 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; /内存地址寄存器递增DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; /外设数据宽度为8位 DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_Byte; /内存数据宽度为8位 DMA_InitStructure.DMA_Mode = DMA_Mode
30、_Circular; /工作在正常缓存模式 DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; /设置DMA通道优先级为高 DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; /禁止DMA通道设置为内存至内存传输 DMA_Init(DMA2_Channel3, &DMA_InitStructure); /初始化 DMA_ITConfig(DMA2_Channel3, DMA_IT_TC, ENABLE);DMA_ITConfig(DMA2_Channel3, DMA_IT_TE, ENABLE);
31、 USART_DMACmd(UART4, USART_DMAReq_Rx, ENABLE);DMA_Cmd(DMA2_Channel3, ENABLE);/使能串口4中断NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;NVIC_Init(&NV
32、IC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = DMA2_Channel3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);USART_Cmd(UART4, ENABLE);/DMA的配置void
33、 DMA_Configuration(void) DMA_InitTypeDef DMA_InitStructure; /* DMA clock enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);/DMA1/串口1 dma配置/ /* DMA1 Channel4 (串口1 TX) Config */ DMA_DeInit(DMA1_Channel4); DMA_InitStructure.DMA_PeripheralBaseAddr = 0x; DMA_InitStructure.DMA_MemoryBaseAddr = (
34、uint32_t)USART1_SEND_DATA; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = 512; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralData
35、Size_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; /DMA工作模式DMA_Mode_Circular DMA_Mode_Normal DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel4, &DMA_InitStructu
36、re); DMA_ITConfig(DMA1_Channel4, DMA_IT_TC, ENABLE); DMA_ITConfig(DMA1_Channel4, DMA_IT_TE, ENABLE); /* Enable USART1 DMA TX request */ USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE); DMA_Cmd(DMA1_Channel4, DISABLE); /使能 /* DMA1 Channel5 (串口1 RX) Config */ DMA_DeInit(DMA1_Channel5); DMA_InitStructure
37、.DMA_PeripheralBaseAddr = 0x; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)USART1_RECEIVE_DATA; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 512; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_Memory
38、Inc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; /DMA工作模式DMA_Mode_Circular DMA_Mode_Normal DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitSt
39、ructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel5, &DMA_InitStructure); DMA_ITConfig(DMA1_Channel5, DMA_IT_TC, ENABLE); DMA_ITConfig(DMA1_Channel5, DMA_IT_TE, ENABLE); /* Enable USART1 DMA RX request */ USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE); DMA_Cmd(DMA1_Channel5, ENABLE); /使能/串口2 dm
40、a配置/ /* DMA1 Channel7 (串口2 TX) Config */ DMA_DeInit(DMA1_Channel7); DMA_InitStructure.DMA_PeripheralBaseAddr = 0x; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)USART2_SEND_DATA; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = 512; DMA_InitStructure.DMA_Perip
41、heralInc = 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_Normal; /DMA工作模式 DMA_Mode_Circul
42、ar DMA_Mode_Normal DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel7, &DMA_InitStructure); DMA_ITConfig(DMA1_Channel7, DMA_IT_TC, ENABLE); DMA_ITConfig(DMA1_Channel7, DMA_IT_TE, ENABLE); /* Enable USART1 DMA TX request */ USART_DM
43、ACmd(USART2, USART_DMAReq_Tx, ENABLE); DMA_Cmd(DMA1_Channel7, DISABLE); /使能 /* DMA1 Channel6 (串口2 RX) Config */ DMA_DeInit(DMA1_Channel6); DMA_InitStructure.DMA_PeripheralBaseAddr = 0x; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)USART2_RECEIVE_DATA; DMA_InitStructure.DMA_DIR = DMA_DIR_Peripher
44、alSRC; DMA_InitStructure.DMA_BufferSize = 512; 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_By
45、te; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; /DMA工作模式DMA_Mode_Circular DMA_Mode_Normal DMA_InitStructure.DMA_Priority = DMA_Priority_Medium; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel6, &DMA_InitStructure); DMA_ITConfig(DMA1_Channel6, DMA_IT_TC, ENABLE); DMA_ITConfig(D
46、MA1_Channel6, DMA_IT_TE, ENABLE); /* Enable USART2 DMA RX request */ USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE); DMA_Cmd(DMA1_Channel6, ENABLE); /使能/串口3 dma配置/ /* DMA1 Channel2 (串口3 TX) Config */ DMA_DeInit(DMA1_Channel2); DMA_InitStructure.DMA_PeripheralBaseAddr =0x; DMA_InitStructure.DMA_Memory
47、BaseAddr = (uint32_t)USART3_SEND_DATA; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = 512; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_Pe
48、ripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; /DMA工作模式 DMA_Mode_Circular DMA_Mode_Normal DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel2, &DM
49、A_InitStructure); DMA_ITConfig(DMA1_Channel2, DMA_IT_TC, ENABLE); DMA_ITConfig(DMA1_Channel2, DMA_IT_TE, ENABLE); /* Enable USART1 DMA TX request */ USART_DMACmd(USART3, USART_DMAReq_Tx, ENABLE); DMA_Cmd(DMA1_Channel2, DISABLE); /使能 /* DMA1 Channel3 (串口3 RX) Config */ DMA_DeInit(DMA1_Channel3); DMA_
50、InitStructure.DMA_PeripheralBaseAddr = 0x; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)USART3_RECEIVE_DATA; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 512; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc
51、 = 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工作模式DMA_Mode_Circular DMA_Mode_Normal DMA_InitStructure.DMA_Priority = DMA_Priority_Med
52、ium; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel3, &DMA_InitStructure); DMA_ITConfig(DMA1_Channel3, DMA_IT_TC, ENABLE); DMA_ITConfig(DMA1_Channel3, DMA_IT_TE, ENABLE); /* Enable USART2 DMA RX request */ USART_DMACmd(USART3, USART_DMAReq_Rx, ENABLE); DMA_Cmd(DMA1_Channel3, ENABLE); /使能/使用DMA发数据中断服务程序/void DMA1_Channel4_IRQHandler(void) DMA_ClearITPendingBit(DMA1_IT_TC4); DMA_ClearITPendingBit(DMA1_IT_TE4); DMA_Cmd(DMA1_Channel4, DISABLE);/关闭DMA USART1_TX_Fin
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年项目利润分配协议
- 2024年采沙场工人劳动合同2篇
- 2024幼儿园幼儿教育项目合作协议3篇
- 2024年环保要求土建工程合同示范文本3篇
- 2025年度数字经济股权优化与产业生态构建协议3篇
- 2024年酒类产品原料供应合同
- 2024版区块链技术应用合同
- 2024版租赁投资回报保证协议3篇
- 2024年铁路货运运输工程居间服务协议3篇
- 2024年绿色施工环保合同:建设工程版
- (新版)焊工(初级)理论知识考试200题及答案
- 满堂脚手架计算书
- MRAS系统标准用户手册
- HAPS系统实现协同仿真验证-基础电子
- 欧洲地下车库诱导通风系统设计手册
- 现代文答题技巧课件2023年中考语文二轮复习
- YS/T 673-2013还原钴粉
- TY/T 3001-2006中国青少年儿童 手腕骨成熟度及评价方法
- GB/T 32545-2016铁矿石产品等级的划分
- 福建省地方标准《先张法预应力混凝土管桩基础技术规程》DBJ13-2023
- 危险作业监护人员培训
评论
0/150
提交评论