是否有參考例程?
按照以下方式來(lái)做遇到了一個(gè)奇怪的情況,接收沒問(wèn)題,但是發(fā)送卻數(shù)據(jù)無(wú)法到達(dá)發(fā)送腳(PC18),使用示波器觀察無(wú)任何波形變化,內(nèi)部模塊都說(shuō)自己發(fā)送出去了,觸發(fā)了DMA傳輸完成中斷和USART3 TC中斷。


以下流程完全正確,只是我外部硬件問(wèn)題,按照如下流程即可實(shí)現(xiàn)此功能。


開啟模塊時(shí)鐘:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);


配置IO重映射:

GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_PIOC, DISABLE);//此條可以不用

GPIO_PinRemapConfig(GPIO_PartialRemap1_USART3, ENABLE);


配置IO:

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_18;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_19;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOC, &GPIO_InitStructure);

配置串口:
USART_InitStructure.USART_BaudRate = 38400;
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_Tx | USART_Mode_Rx;
USART_Init(USART3, &USART_InitStructure);