增加写功能: #include <AT89X51.H> #include <stdio.h> #ifdef MONITOR51 /* Debugging with Monitor-51 needs */ char code reserve [3] _at_ 0x23; /* space for serial interrupt if */ #endif /* Stop Exection with Serial Intr. */ sbit L1=P1^0; void delay02s(void) //延时0.2秒子程序 { unsigned char i,j,k,l; for(l=100;l>0;l--) for(i=20;i>0;i--) for(j=20;j>0;j--) [hide] for(k=248;k>0;k--); } [/hide] void main(void) { int u; #ifndef MONITOR51 SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD &line;= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 221; /* TH1: reload value for 1200 baud at 16MHz */ TR1 = 1; /* TR1: timer 1 run */ TI = 1; /* TI: set TI to send first char of UART */ #endif PRINTF必须 printf ("Hello World\n"); while(1) { L1=0; printf("0xff p2 %02x\n",P2); delay02s(); L1=1; www.shengfang.org printf("0xff p2 %02x\n",P2); delay02s(); } } void Watchp10() { DWORD cSBUF, pSBUF; Agsi.ReadSFR(0x90, &cSBUF, &pSBUF, 0xFF); dd=~dd;www.shengfang.org Agsi.WriteSFR(0xA0,dd,0xff);www.shengfang.org CString str; DWORD d=GetTickCount(); str.Format("%d,%x\r\n",d,pSBUF); TRACE(str); } 很简单的代码,往P2写0X00或者0XFF,然后uVision C51打印结果。 21740411,ff 21745027,fe 21748793,ff 21752748,fewww.shengfang.org 21756233,ff HELLO WORLD 0XFF P2 FF00 0XFF P2 00 字体:大 中 小 |