打印
[STM32F4]

stm32f429i Discovery USART problem

[复制链接]
1624|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
电子write_cai|  楼主 | 2014-4-9 17:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 电子write_cai 于 2014-4-9 17:35 编辑

Hi,all:
       The  stm32f429i Discovery USART  interface  is   PA10,PA9.

The code is correct. but tx  data can not captured by the oscilloscope.

add the coding....

/*******Main code*****/
int main(void)
{

        delay_init();
       
        USART1_init();
        NVIC_Config();
        LED_Init();

  while (1)
  {
                LED0=1;                                               
                LED1=1;
                delay_ms(500);
                LED0=0;                                               
                LED1=0;
                delay_ms(500);
       
                printf("STM32F429I DISCOVERY USART INITOK\r\n");
  }
}

/***********USART_Init()********/
void USART1_init()
{
        GPIO_InitTypeDef GPIO_InitStructure;
        USART_InitTypeDef USART_InitStructure;
        USART_ClockInitTypeDef USART_ClockInitStruct;
   
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA , ENABLE);
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
        
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);      
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);

      
        GPIO_StructInit(&GPIO_InitStructure);                                                
        GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;
        GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;                                    
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
        GPIO_Init(GPIOA,&GPIO_InitStructure);
            
        /*??PA10?Rx??*/
        GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;
        GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;                                    
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_Init(GPIOA,&GPIO_InitStructure);

        /*??USART1,?????Cotex M3??*/
        USART_StructInit(&USART_InitStructure);
        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_Init(USART1, &USART_InitStructure);
        USART_ClockStructInit(&USART_ClockInitStruct);  
        USART_ClockInit(USART1, &USART_ClockInitStruct);

        USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);                          
        USART_Cmd(USART1, ENABLE);   
        USART_ClearFlag(USART1, USART_FLAG_TC);
}
/*********NVIC_Config(void)***********/
void NVIC_Config(void)
{
      NVIC_InitTypeDef NVIC_InitStructure;
      NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);                        
      NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;                    
      NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;            
      NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;                     
      NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;                       
}
/*********Usart Interrupt**********/
void USART1_IRQHandler(void)
{
        uint16_t uData=0;
  if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)               //???????
  {
        USART_ClearITPendingBit(USART1,USART_IT_RXNE);
        uData=USART_ReceiveData(USART1);
        USART_SendData(USART1, uData);                                       //???????
  }
}
沙发
mmuuss586| | 2014-4-9 18:38 | 只看该作者

有空我也测测

使用特权

评论回复
板凳
airwill| | 2014-4-9 20:18 | 只看该作者
从手册可能, PA9, PA10 是完全空脚. 设置好, TxD 肯定能够测到波形.
可以短接这两个引脚, 看看自发自收, 能否收到数据.
如果能够收到, 怀疑是你的示波器设置问题了

使用特权

评论回复
地板
电子write_cai|  楼主 | 2014-4-10 08:46 | 只看该作者
airwill 发表于 2014-4-9 20:18
从手册可能, PA9, PA10 是完全空脚. 设置好, TxD 肯定能够测到波形.
可以短接这两个引脚, 看看自发自收, 能 ...

if you have the PCB,you can help me to test it . thanks

使用特权

评论回复
5
yinhaix| | 2015-8-12 20:22 | 只看该作者

使用特权

评论回复
6
songchenping| | 2015-8-12 21:00 | 只看该作者
是官方代码吗

使用特权

评论回复
7
songchenping| | 2015-8-12 21:01 | 只看该作者
建议还是用示波器好好测测波形吧

使用特权

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

本版积分规则

个人签名:只要你是拼多多新用户就可以加我微信,微信号772880135验证您是新用户后立刻微信转你20元。欢迎朋友加我微信,多年21ic用户,诚信为本!

157

主题

1535

帖子

3

粉丝