示例程序:

  #include <stdio.h>

  .

  .

  void UART_send_byte(char dat);

  void UART_send_string(unsigned char *buf);

  .

  unsigned char TX_Buf[10];

  sprintf(TX_Buf,"D%f",Distance);

  UART_send_string(TX_Buf);

  Delay_ms(500);

 

 

  

  /*
  * UART 发送一字节
  */

  void UART_send_byte(char dat)
  {
    SBUF = dat;
    while (TI == 0);
    TI = 0;
  }

  /*
  * UART 发送字符串
  */
  void UART_send_string(unsigned char *buf)
  {
    while (*buf != '\0'){
      UART_send_byte(*buf++);
    }
  }

 

相关文章:

  • 2022-01-05
  • 2021-08-08
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2021-08-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
相关资源
相似解决方案