標題: 51單片機發(fā)送一個字符串失敗 [打印本頁]

作者: yuzhihang123    時間: 2021-4-4 15:52
標題: 51單片機發(fā)送一個字符串失敗
#include "uart.h"
void main(void)
{
    uart_init();
          uart_send_byte('A');
          uart_send_sting("xxxxxxxx");
    while(1);
}
這是主函數(shù);
#include "uart.h"
//#include <intrins.h>
void uart_init(void)
{
         TMOD = 0X20;
         SCON = 0X50;
         TH1 = 0XF3;
         TL1 = 0XF3;//4800
   PCON  = 0X80;
         ES =1;//¿aÖD¶Ï
         EA = 1;
         TR1 = 1;               
}

void uart_send_byte(unsigned char c)
{
   //μúò»2½£¬·¢Ëíò»¸ö×Ö½ú
         SBUF = c;
         while(!TI);
         TI  = 0;
}

void uart_send_sting(unsigned char *str)
{
   while(*str != '\0')
             {
                            uart_send_byte(*str);
          str++;                        
                         }
}
這是串口的子函數(shù)

作者: 人人學會單片機    時間: 2021-4-4 18:16
串口1打印程序 可以打印3個十六位的變量 波特率9600 http://www.torrancerestoration.com/bbs/dpj-201660-1.html

串口發(fā)送 不需要while死等 串口接收執(zhí)行軟件復位 http://www.torrancerestoration.com/bbs/dpj-200927-1.html
作者: man1234567    時間: 2021-4-6 17:36
將         ES =1;//愀D
         EA = 1;
注釋掉試試




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1