单片机核心部分源程序如下:
… …
//generate pulse signal
//period= the period of pulse signal
//positive=the length of positive voltage
timer0() interrupt 1 using 1 {
unsigned int temp;
out=1; //output VOH
temp=65535-period;
TL0=temp; //set value for timer0
TH0=temp>>8;
temp=65535-positive;
TL1=temp; //set value for timer1
TH1=temp>>8;
TR1=1;
TR0=1; //start timer1, 0
}
timer1() interrupt 3 using 2 {
out=0; //timer1记满,output VOL
TR1=0; //stop timer1
}
…