[mw_shl_code=c,true]void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure; //?ù?÷?????á????±???
//USART1_TX -> PC10 , USART1_RX -> PC11
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //????PC.10(TXD) ?? PC.11
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //??????????50MHZ
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //?????????????????ì????
GPIO_Init(GPIOC,&GPIO_InitStructure); //??????GPIOC?????÷
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; //????PC.10(TXD) ?? PC.11?¨RXD?©
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //??????????50MHZ
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //??????????????????
GPIO_Init(GPIOC,&GPIO_InitStructure); //??????GPIOA?????÷
RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3,ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3,DISABLE);
//??USART3??TXD??RXD????????PC10??pc11
GPIO_PinRemapConfig(GPIO_PartialRemap_USART3,ENABLE);
}
void USART3_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate =9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(USART3, &USART_InitStructure);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
USART_Cmd(USART3,ENABLE);
}[/mw_shl_code]
[mw_shl_code=c,true]void USART3_IRQHandler(void)
{
if(USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == SET)
{
USART_ClearFlag(USART3,USART_IT_TC);
ch=USART_ReceiveData(USART3);
USART_SendData(USART3, ch);
// TIM_Cmd(TIM2, ENABLE);
}
}[/mw_shl_code]
我想看看我的问题出在哪里
|