打印

STM32-107的串口发送

[复制链接]
1517|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
loco_v|  楼主 | 2013-4-25 16:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
哪位大虾给我看下有没有问题,我的串口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);     
}
我不明白的是我的串怎么会发不出数据呢,谁知道的啊,求解答!!!!!!

相关帖子

沙发
阿南| | 2013-4-25 16:12 | 只看该作者
硬件上先把接口去掉,用示波器测一下是否正常,以免是硬件的问题。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

15

帖子

0

粉丝