/*use TM50 timer control LED,use Frh 8M,8000000/8192=976.5Hz,f0=240,240/976.5=0.24S,0.24*20=4.8S*/
#pragma sfr
#pragma di /*close interrupt*/
#pragma ei /*open interrupt*/
#define UINT8 unsigned char
#define UINT16 unsigned int
#pragma interrupt INTTM50 vect_INTTM50
UINT16 counter = 0;
void init_TM50()
{
TCE50 = 0; /*stop timer50*/
CRC00 = 0;
TCL50 = 0x07;
CR50 = 0xf0;
TMC50 = 0x85;
TMIF50 = 0;
TMMK50 = 0;
}
void restart_TM50()
{
TMIF50 =0;
TCE50 = 0;
TCE50 = 1;
}
void main()
{
IMS = 0xc8; /*fast RAM 1024byte,32kbROM*/
IXS = 0x0c;
OSCCTL = 0x00;
PCC = 0x00; /*main systerm time,Fcpu=Fxp*/
RCM = 0x82; /*stop lrstop,open rstop*/
MOC = 0x80; /* stop X1 or EXCLK*/
MCM = 0x05; /*high systerm time*/
PM6 = 0xf0;
P6 = 0xff;
DI(); /*stop INT*/
init_TM50();
restart_TM50();
EI();
while( 1 )
{
;
}
}
__interrupt void vect_INTTM50(void)
{
counter ++;
if( counter >= 20 )
{
counter = 0;
P6 = ~P6;
}
}
用户377235 2012-5-29 12:00
想问下楼主用TM50和TM00两个中断怎么嵌套使用?有样例程序吗?