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

📄 debug.c

📁 一个具体的项目程序
💻 C
字号:
#include <REG52.H>
#include "Debug.H"

xdata unsigned char hex[]={"0123456789ABCDEF"}; //为ascii-》hex的转换表

/*
void DebugInit(void)
{

	TMOD=0x21;
	SCON=0x50;
	TH1=0xfd;
	TL1=0xfd ;
	IP=0x10;
	PCON|=0x80;
	TR1=1;
	EA=0;
	ET0=0;
	ES=0;
	RI=0;
}
*/
unsigned char DebugSend(unsigned char de_data)
{

    unsigned int Dtime=0;

      SBUF=de_data;
      do{
			Dtime++;
			if(Dtime>1000)
				return 1;

      }while(!TI);
    TI=0;
	return 0;
}

void Debughex(unsigned char senddata)
{
	unsigned char ch;
	ch=senddata>>4;

	DebugSend(hex[ch]);
	ch=senddata&0x0f;

	DebugSend(hex[ch]);

}
void DebugString(unsigned char *string)
{
	while(*string!=0)
	{
		DebugSend(*string);
 		string++;
	}
}

void DebugData(unsigned int length,unsigned char x,unsigned char *buff)
{
	unsigned int i=0,j=0;
	unsigned int pos=0;
	unsigned char temp;

	for(i=0;i<length/x;i++)
	{
		for(j=0;j<x;j++)
		{
			temp=buff[pos];
			Debughex(temp);
			temp<<=2;
			DebugString(" ");
			pos++;
		}
		DebugString("\r\n");
	}
	for(i=0;i<(length%x);i++)
	{
		Debughex(buff[pos]);
		DebugString(" ");
		pos++;
	}
	DebugString("\r\n");
}

⌨️ 快捷键说明

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