打印

STM32F103VET6串口问题

[复制链接]
1408|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lucjn|  楼主 | 2012-11-22 18:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本人在调试STM32过程中遇到一个串口问题初始化:
    USART_InitTypeDef USART_InitStructure;
    USART_ClockInitTypeDef USART_ClockInitStructure;

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);  



USART_InitStructure.USART_BaudRate = 115200;

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_ClockInitStructure.USART_Clock = USART_Clock_Disable;

USART_ClockInitStructure.USART_CPOL = USART_CPOL_High;

USART_ClockInitStructure.USART_CPHA = USART_CPHA_1Edge;

USART_ClockInitStructure.USART_LastBit = USART_LastBit_Enable;


USART_Init(USART1, &USART_InitStructure);

USART_ClockInit(USART1, &USART_ClockInitStructure);



    GPIO_InitTypeDef GPIO_InitStructure;


    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);


    GPIO_InitStructure.GPIO_Pin = RadioBox_GPIOA_UART2_Tx;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;   //设置为推挽复用输出模式

    GPIO_InitStructure.GPIO_Pin = RadioBox_GPIOA_UART2_Rx;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;   //设置为上拉输入模式
    GPIO_Init(GPIOA, &GPIO_InitStructure);



USART_SendData(CDMAPort,*lb);
        while(USART_GetFlagStatus(CDMAPort, USART_FLAG_TXE) == RESET)



发送完数据在while(USART_GetFlagStatus(CDMAPort, USART_FLAG_TXE) == RESET)一直死等,请问是什么原因?
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

13

帖子

0

粉丝