|
/*QUERY MODE 16TM*/
#include "macrodriver.h"
#include "system.h"
#include "port.h"
#define LED_R1 P4.5
#define LED_R2 P4.6
#define LED_R3 P4.7
bit flag;
int count=0;
int count_2=0;
extern void hdwinit();
void TM00_Init( void )
{
TMC00 = 0x00; /*STOP TM00 OPERATION*/
SetIORBit(MK0, 0x20); /*DISABLE TMOO INTERRUPT*/
ClrIORBit(IF0, 0x20); /*DISABLE TMOO INTERRUPT*/
PRM00 |= 0x0; /* CHOOSE CLOCK */
ClrIORBit(CRC00, 0x01); /* TM00 COMPARE REG */
CR000 = 0x1f3f; /*SET COUNT NUMBER*/
}
void TM00_Start( void )
{
//ClrIORBit(MK0, 0x20); /* INTTM000 enable */
TMC00 = 0x0c; /* interval timer start */
}
void TM00_Stop( void )
{
TMC00 = 0x0;
//SetIORBit(MK0, 0x20); /* INTTM000 disable */
ClrIORBit(IF0, 0x20); /* INTTM000 disable */
}
void inter_service(void)
{
if( TMIF000 ) /*16TM overflow flag*/
{
count++;
TMIF000 = 0;
}
if(count==50)
{
count_2++;
if(count_2==20)
{
LED_R1 = ~LED_R1;
count_2 = 0;
}
count = 0;
}
}
void main( void )
{
/* TODO. add user code */
hdwinit();
TM00_Stop();
TM00_Init();
TM00_Start();
flag = 0;
while(1)
{
inter_service();
}
}
1s计时查询方式ourdev_393254.rar(文件大小:36K) (原文件名:TM16-QUERY.rar) |
|