標(biāo)題: Single Chip U-art simple string通訊 [打印本頁]

作者: liuzong    時間: 2013-7-9 14:00
標(biāo)題: Single Chip U-art simple string通訊
                                                                                                #include<reg52.h>
typedef unsigned char uint8;
typedef unsigned int  uint16;
uint8 STR[]="hello world!\n";
void uart_init()
{
        SCON=0x50;
        TMOD=0x20;
        TH1=0xfd;
        TL1=0xfd;
        TR1=1;
}
void delay(uint16 timer)
{
        while(timer--);
}
void uart_send_byte(uint8 dat)
{
                SBUF=dat;
                while(!TI);
                TI=0;
}
void uart_send_string(uint8 *pointer)
{
        while(*pointer!='\0')
        {
       
                uart_send_byte(*pointer++);
        }

}
main()
{
        uart_init();
        uart_send_string(STR);
        delay(30000);
}


                                                                                            

                                                                                                                                                                                                                                                                                                                                                                                                                       





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