|
|
发表于 2021-4-17 21:03:52
来自手机
|
显示全部楼层
楼主代码有哪位大神给分析一下吗?#include"reg52.h" #include "intrins.h" #define u8 unsigned char #define u16 unsigned int sfr P3M1=0xb1; sfr P3M0=0xb2; sfr AUXR=0x8e; sfr T2H=0xd6; sfr T2L=0xd7; sfr IE2=0xaf; sbit outio=P3^4; sbit k0=P3^0; sbit k1=P3^1; sbit k2=P3^2; u16 ppmtemp,PPMread[9],outtemp; u8 channel,i,y,yichuFlag,ch; void zhongduan() interrupt 2 { TR0=0; ppmtemp=TH0; ppmtemp=(ppmtemp<<8)|TL0; TH0=0; TL0=0; TR0=1; if(ppmtemp>2500|| yichuFlag) { i=1; yichuFlag=0; } switch(i) { case 1: break; case 2: PPMread[i-1]=ppmtemp; break; case 3: PPMread[i-1]=ppmtemp; break; case 4: PPMread[i-1]=ppmtemp; break; case 5: PPMread[i-1]=ppmtemp; break; case 6: PPMread[i-1]=ppmtemp; break; case 7: PPMread[i-1]=ppmtemp; break; case 8: PPMread[i-1]=ppmtemp; break; case 9: PPMread[i-1]=ppmtemp; break; default:break; } i++; } void shuchu() interrupt 12 { ch=k0; ch=(ch<<1)|k1; ch=(ch<<1)|k2; outtemp=PPMread[ch+1]; y++; switch(y) { case 1: outio=0; T2H=(65536-outtemp)/256; T2L=(65536-outtemp)%256; break; case 2: outio=1; T2H=(45536+outtemp)/256; T2L=(45536+outtemp)%256; y=0; break; } } void dingsqiTimer0(void) interrupt 1 { yichuFlag=1; } void main() { while(1) { P3M0=0x10; P3M1=0x08; EA=1; EX1=1; IT1=1; ET0=1; TMOD=0x11; IE2=0x04; AUXR=0x10; PX1=1; } } |
| |