哪位大虾给我看下有没有问题,我的串口3发不出数据,我的串口3用做422的接口。源代码如下:
static void AppTaskKbd (void *p_arg)
{
USART3_SendString("A");
while(USART_GetITStatus(USART3, USART_IT_TC)==SET)
{
GPIO_SetBits(GPIOD,GPIO_Pin_14);
delay(500);
GPIO_ResetBits(GPIOD,GPIO_Pin_14);
delay(500);
}
}
void USART3_SendString(uint8_t *ch)
{
while(*ch!=0)
{
while(!USART_GetFlagStatus(USART3, USART_FLAG_TXE));
USART_SendData(USART3, *ch);
ch++;
}
USART_ITConfig(USART3, USART_IT_TXE, ENABLE);
}
void Init_Usart(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO,ENABLE)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE);
GPIO_PinRemapConfig(GPIO_FullRemap_USART3, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOD, &GPIO_InitStructure); Usart_Configuration(115200);
}
void Usart_Configuration(uint32_t BaudRate)
{
USART_InitTypeDef USART_InitStructure; USART_InitStructure.USART_BaudRate =BaudRate ; 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); USART_Cmd(USART3, ENABLE);
}
我不明白的是我的串怎么会发不出数据呢,谁知道的啊,求解答!!!!!! |