打印

STM32F107的IRDA不能工作

[复制链接]
1286|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
gampt|  楼主 | 2014-5-30 10:47 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

发送程序
USART_InitStructure.USART_BaudRate = 9600;//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;

  /* Configure the USARTy */
  USART_Init(USARTy, &USART_InitStructure);
  /* Enable the USARTy */
  USART_Cmd(USARTy, ENABLE);
  /* Set the USARTy prescaler */
  USART_SetPrescaler(USARTy, 0x1);
  /* Configure the USARTy IrDA mode */
  USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);

  /* Enable the USARTy IrDA mode */
  USART_IrDACmd(USARTy, ENABLE);


  while (1)
  {
   USART_SendData(USARTy, i++);//i unsigned char
   delay(1000000);
  }
}
接收程序

  USART_InitStructure.USART_BaudRate = 9600;//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;
  
  /* Configure the USARTy */
  USART_Init(USARTy, &USART_InitStructure);


  STM_EVAL_COMInit(COM2, &USART_InitStructure);
  printf("\n\rUSART Printf Example: retarget the C library printf function to the USART\n\r");

  /* Enable the USARTy */
  USART_Cmd(USARTy, ENABLE);

  /* Set the USARTy prescaler */
  USART_SetPrescaler(USARTy, 0x1);
  /* Configure the USARTy IrDA mode */
  USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);

  /* Enable the USARTy IrDA mode */
  USART_IrDACmd(USARTy, ENABLE);

  while (1)
  {
    /* Wait until a byte is received */
    while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET)
    {
           count++;
           if(count > 1000000)
           {
           printf("\n\r 等待接收数据 \n\r");
           count = 0;
           }
    }
    /* Read the received byte */
     //ReceivedData = (JOYState_TypeDef)USART_ReceiveData(USARTy);
     REV = (unsigned char)USART_ReceiveData(USARTy);
         //USART_SendData(USARTy,i++);
         //REV = 255;
         printf("\n\r 接收到的数据为:%d%d%d \n\r",REV/100,REV%100/10,REV%10);
         Delay(5000000);
  }
}
电路图:
现象:
       发送端 TXD和RXD都有波形,用示波器,至于TFDU4300有没有将数据发出就没法检测了
       接收端都没有波形
     
      USE_STDPERIPH_DRIVER, STM32F10X_CL, USE_STM3210B_EVAL

     在官方库的基础上改的
   


相关帖子

沙发
夏夜星语| | 2014-5-30 11:05 | 只看该作者
快来大神解答吧:D

使用特权

评论回复
板凳
gampt|  楼主 | 2014-5-30 13:45 | 只看该作者
大神 在哪里呢

使用特权

评论回复
地板
gampt|  楼主 | 2014-6-4 10:00 | 只看该作者
好几天了 大神在哪里啊

使用特权

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

本版积分规则

个人签名:瞎折腾

18

主题

190

帖子

1

粉丝