void time (unsigned int ucMs); void initUart(void);
void main (void) {
unsigned char ucTimer;
initUart(); ucTimer=0; while (1) {
if(ucTimer<=0x0f){ printf(\"current data-out of P2-port:0%BX\\n\ } else{ printf(\"current data-out of P2-port:%BX\\n\ } P2=ucTimer; ucTimer++; time(1000); } }
void initUart(void) {
SCON=0x50;
RCAP2H=(65536-(3456/96))/256; RCAP2L=(65536-(3456/96))%256; T2CON=0x34; TI =1; }
void delay_5us(void) {
_nop_(); _nop_(); _nop_();
_nop_(); }
void delay_50us(void) {
unsigned char i; for(i=0;i<4;i++) {
delay_5us(); } }
void delay_100us(void) {
delay_50us(); delay_50us(); }
void time(unsigned int ucMs) {
unsigned char j; while(ucMs>0){
for(j=0;j<10;j++) delay_100us(); ucMs--; } }
因篇幅问题不能全部显示,请点此查看更多更全内容