STM32F107的IRDA不能工作

[复制链接]
1758|3
 楼主| gampt 发表于 2014-5-30 10:47 | 显示全部楼层 |阅读模式

发送程序
  1. USART_InitStructure.USART_BaudRate = 9600;//115200;
  2.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  3.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  4.   USART_InitStructure.USART_Parity = USART_Parity_No ;
  5.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  6.   USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  7.   /* Configure the USARTy */
  8.   USART_Init(USARTy, &USART_InitStructure);
  9.   /* Enable the USARTy */
  10.   USART_Cmd(USARTy, ENABLE);
  11.   /* Set the USARTy prescaler */
  12.   USART_SetPrescaler(USARTy, 0x1);
  13.   /* Configure the USARTy IrDA mode */
  14.   USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);

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


  17.   while (1)
  18.   {
  19.    USART_SendData(USARTy, i++);//i unsigned char
  20.    delay(1000000);
  21.   }
  22. }
接收程序

  1.   USART_InitStructure.USART_BaudRate = 9600;//115200;
  2.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  3.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  4.   USART_InitStructure.USART_Parity = USART_Parity_No ;
  5.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  6.   USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  7.   
  8.   /* Configure the USARTy */
  9.   USART_Init(USARTy, &USART_InitStructure);


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

  12.   /* Enable the USARTy */
  13.   USART_Cmd(USARTy, ENABLE);

  14.   /* Set the USARTy prescaler */
  15.   USART_SetPrescaler(USARTy, 0x1);
  16.   /* Configure the USARTy IrDA mode */
  17.   USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);

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

  20.   while (1)
  21.   {
  22.     /* Wait until a byte is received */
  23.     while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET)
  24.     {
  25.            count++;
  26.            if(count > 1000000)
  27.            {
  28.            printf("\n\r 等待接收数据 \n\r");
  29.            count = 0;
  30.            }
  31.     }
  32.     /* Read the received byte */
  33.      //ReceivedData = (JOYState_TypeDef)USART_ReceiveData(USARTy);
  34.      REV = (unsigned char)USART_ReceiveData(USARTy);
  35.          //USART_SendData(USARTy,i++);
  36.          //REV = 255;
  37.          printf("\n\r 接收到的数据为:%d%d%d \n\r",REV/100,REV%100/10,REV%10);
  38.          Delay(5000000);
  39.   }
  40. }
电路图:
现象:
       发送端 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

粉丝
快速回复 在线客服 返回列表 返回顶部