|
|
各位大佬我想請(qǐng)教一下我程序是哪里有問題,我用仿真和示波器都測不出來正確的波形,求指教
單片機(jī)源程序如下:
- #include <REGX51.H>
- unsigned int condition=80;
- //#define pin P1
- sbit pin=P1^0;
- void main()
- {
- TMOD=0x01;
- TL0 = 0xec; //設(shè)置定時(shí)初值
- TH0 = 0xFF;
- EA=1;
- ET0=1;
- TR0 = 1;
- }
- void Isr01() interrupt 1
- {
- static unsigned int cnt;
- TL0 = 0xec; //設(shè)置定時(shí)初值
- TH0 = 0xFF;
- cnt++;
- if(cnt>=100)
- {
- cnt=0;
- }
- if(cnt<condition)
- {
- pin=0;
- }
- else
- {
- pin=1;
- }
- }
復(fù)制代碼
|
|