⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serial.c

📁 51单片机web的ucosii
💻 C
字号:

#ifndef  OS_MASTER_FILE
#include    <CORE\includes.h>
#endif

#include "serial.h"
#include <global_para.h>
#include <LCD\LCD.h>


sbit   LED_RED  = P3 ^ 3;
sbit   LED_GRE  = P3 ^ 4; 

void InitSerial_0(void)
{
	///////////////////////////////////////////////////////////////////////////
	//-if you need isd(in system debugger)you need add the list code in your main
	//--------------add for serial bebug s0----------zhzhl-------
	SCON  = 0x50;      /* enable serial uart & receiver  s0,mode 1    */
	PCON = PCON | 0x80;

    TMOD|=0X20; //TIMER1: MODE 2, ;
	TH1=247;    //32M-->18938
	TL1=247;
	TR1=1;     //TIMER1 START;
	//-----------end of s0 initial ----------------------------
//	ES=1;
}


void serial(void) reentrant interrupt 4
{    
    if(RI)
        RI=0;
   // if(TI) TI=0;    
}
//----------------FOR DEBUG-----------------------------
//////////////////////////////////////////////////////////////////
void Uart0_print(char *p)
  {
    // ES=0;      //disabe uart0 interrupt;
     TI=1;
     while(*p)
	 {
         if(*p==10)
              {
	        	TI=0;
                SBUF=0x0d;
               while(!TI);
	      }
          TI=0;
          SBUF=(*p);
          ++p;
          while(!TI);
      
	  }
//     while(!TI);
	 TI=0;
    // ES=1;
  }
//--------------------------------------------------------*/

////////////////////////////////////////////////////////////////
//print xdata memory(hex);
//pxdata: start address
//n: byte number
//e.g: Uart0_printR(0x8800,4); will print: 0x** ** ** **;
////////////////////////////////////////////////////////////////

void Uart0_printR(BYTE xdata *pxdata, WORD n)
{
 WORD i;
 //ES=0;   //stop uart1 interrupt;
 TI=0;

 for(i=0;i<n;i++)
 {
  // j=(*(pxdata+i));
   TI=0;
   SBUF=*(pxdata+i);
   while(!TI);

 }
 //ES=1;
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -