#include "HT66F40.h"
#define uint unsigned int
#define uchar unsigned char
#define _pc5 _20_5
#define _t1aio1 _49_5
#define _t1bio1 _4a_5
#define _emi _10_0
#pragma vector timebase0 @ 0x24
uchar disaddr;
uchar nelcmd;
uchar voltadpwm;
const uchar led_num_tab[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
/**************************************************
void send_8bit()
{uchar k;
k=8;
while(k)
{if((disaddr&0x01)==1)
_pc|=0x01;
else
_pc&=0xfe;
#asm
nop
nop
#endasm
//_pb&=0xef;
_pc5=0;
#asm
clr WDT
nop
#endasm
_pc5=1;
//_pb|=0x10;
k--;
disaddr>>=1;
}
}
void delay()
{unsigned long int i,j;
for(i=650;i>0;i--)
for(j=50;j>0;j--);
}
void display_temperature()
{uchar i,j;
//i=led_num_tab[ccb1&0x0f];
//j=led_num_tab[(ccb1&0xf0)>>4];
i=led_num_tab[voltadpwm&0x0f];
j=led_num_tab[(voltadpwm&0xf0)>>4];
disaddr=0xc4;
_pc&=0Xfb;
send_8bit();
disaddr=i;
send_8bit();
_pc|=0x04;
disaddr=0xc3;
_pc&=0xfb;
send_8bit();
disaddr=j;
send_8bit();
_pc|=0x04;
delay();
}
/********************************************************
void timebase0()
{_pc&=0xfe;
}
void main()
{_pawu=0;
_papu=0;
_pbpu=0;
_pcpu=0;
_pdpu=0;
_pepu=0;
_pfpu=0;
_pac=0x7f;
_pbc=0;
_pcc=0x10;
_tbc=0xf0;
_intc2=6;
_tm1c0=0x19;
_tm1c1=0xa8;
_tm1c2=0xac;
_tmpc0=0xa1;
_cp0c=8;
_cp1c=8;
_acerl=0x7f;
_adcr1=3;
_adcr0=0x10;
_prm0=0x53;
_prm1=0x05;
_prm2=0x2f;
_bp|=0;
//disaddr=0x98;
//_pc&=0xfb;
//send_8bit();
//_pc|=0x04;
_emi=1;
_t1aio1=1;
_tm1ah=0;
_tm1al=0x40;
_t1bio1=1;
_tm1bh=0;
_tm1bl=0x40;
//voltadpwm=0x27;
while(1)
{//display_temperature();
//delay();
;
}
}
上面的程序,去掉星号中间的部分就可以产生PWM波,加上就不行,请高手指教。谢谢! |