此帖出自stm32/stm8论坛
最新回复
//usart init
USART_InitStructure.USART_BaudRate = 19200;
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(USART3, &USART_InitStructure);
/***************DMA*************************/
USART_DMACmd(USART3, USART_DMAReq_Tx, ENABLE);
USART_DMACmd(USART3, USART_DMAReq_Rx, ENABLE);
/* DMA1 Channel5 RX Config */
DMA_DeInit(DMA1_Channel3);
DMA_InitStructure.DMA_PeripheralBaseAddr = USART3_DR_Base;
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)Received_Data_Buffer;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = COM_PACKET_SIZE;
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_Low;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel3, &DMA_InitStructure);
DMA_Cmd(DMA1_Channel3, ENABLE);
USART_Cmd(USART3, ENABLE);
DMA_ITConfig(DMA1_Channel3, DMA_IT_TC, ENABLE);
/* DMA1 Channel4 TX Config */
DMA_DeInit(DMA1_Channel2);
DMA_InitStructure.DMA_PeripheralBaseAddr = USART3_DR_Base;
//DMA_InitStructure.DMA_MemoryBaseAddr = (u32)(USART_INIT_MESSAGE+6);// " OK!"
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)Send_Data_Buffer;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = sizeof(Received_Data_Buffer);
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_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_Low;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel2, &DMA_InitStructure);
DMA1_Channel2->CNDTR= SEND_BUFFER_SIZE;
DMA_Cmd(DMA1_Channel2, ENABLE); //触发一次,使TC置1
}
dma中断时处理,不需要串行中断
void DMAChannel3_IRQHandler(void)
{
DMA1->IFCR |= DMA1_FLAG_TC3; //清除传输完成标记
if (Received_Data_Buffer[0] == (u8)'R') {
Com_Received_Command=CHG_DATA_BIGMODE((Received_Data_Buffer+0));
Com_Received_Parameter=*(u32 *)(Received_Data_Buffer+4);
} else {
Com_Received_Command=0;
}
}
详情
回复
发表于 2013-7-23 17:36
点评 | ||
|
||
| |
个人签名上传了一些书籍资料,也许有你想要的:https://download.eeworld.com.cn/user/chunyang
|
|
| |
|
|
回复 沙发chunyang 的帖子
此帖出自stm32/stm8论坛
| ||
|
||
回复 板凳huo_hu 的帖子
此帖出自stm32/stm8论坛
点评 | ||
|
||
| |
个人签名我的博客
|
|
回复 6楼zhaojun_xf 的帖子
此帖出自stm32/stm8论坛
| ||
|
||
| |
个人签名上传了一些书籍资料,也许有你想要的:https://download.eeworld.com.cn/user/chunyang
|
|
回复 5楼小小小小菜鸟 的帖子
此帖出自stm32/stm8论坛
点评 | ||
|
||
回复 8楼chunyang 的帖子
此帖出自stm32/stm8论坛
点评 | ||
|
||
回复 9楼huo_hu 的帖子
此帖出自stm32/stm8论坛
点评 | ||
|
||
|
|
个人签名上传了一些书籍资料,也许有你想要的:https://download.eeworld.com.cn/user/chunyang
|
|
| |
|
|
| |
|
|
| |
|
|
| |
个人签名上传了一些书籍资料,也许有你想要的:https://download.eeworld.com.cn/user/chunyang
|
|
| |
个人签名上传了一些书籍资料,也许有你想要的:https://download.eeworld.com.cn/user/chunyang
|
|
| |
|
|
| |
个人签名上传了一些书籍资料,也许有你想要的:https://download.eeworld.com.cn/user/chunyang
|
|
论坛威望大于30000或网友提名:坛子里公认的技术导师
曾经的版主且威望大于2000,或对EEWORLD论坛有突出贡献的坛友
EEWorld Datasheet 技术支持