/*----------------------------*/ /* Include Header File */ /*----------------------------*/ #include "stc32.h" /* stc32 register address define and function prototype*/ #include "math.h" /*----------------------------*/ /* Global variable definition */ /*----------------------------*/ int TICK=0, TICK0=0, TICK1=0; int LED=0; int rear_i = -1, front_i = -1; int rear_o = -1, front_o = -1; char queue_i[ MAXQ ]; char queue_o[ MAXQ ]; int rear_KBD = -1, front_KBD = -1; char queue_KBD[ MAXKBD ]; char KBD_old[] = { 0, 0, 0, 0 }; int KBD_cnt = 0; char KBD_T1[] = "FEDCB369A2580147"; char PORTC_REG = 0; int rear_LCD = -1, front_LCD = -1; char queue_LCD[ MAXLCD ]; int bias[] = { 0, 0 }; real SCALAR[] = { 1.0, 1.0 }; int ain[2]; float ainf[2]; int flag = 0; int Flag =0; char cmd, keybd,str[20]; int temp, axis = 0; int count=0; int temp1; int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//last day of month int year=2001,month=9,date=20,hour=18,min=51,sec=2;//set start timer char DATA[31],DATA1[10]; void main() { stc32_init(); settimer1freq(1); inittimer1isr(); }//main /*====================================*/ /* Begin of ISR */ /* -------------------------------------------- */ /* External Hardware Interrupt /INT2 User defined ISR -------------------------------------------- */ void c_int02() { count++; asm("\tNOP"); asm("\tNOP"); } /* -------------------------------------------- */ /* External Hardware Interrupt /INT3 User defined ISR -------------------------------------------- */ void c_int03() // 8.3333 KHz { TICK++; asm("\tNOP"); asm("\tNOP"); } /*-----------------------------------------------------*/ /* Timer 0 Interrupt, Frequency 1kHz (100kHz<=>10usec) */ /*-----------------------------------------------------*/ /* --------------------------------------------- */ /* Timer1 for user */ /* Timer1 is set by settimer1freq( Freq1 ); inittimer1isr(); */ /* --------------------------------------------- */ void c_int08() { TICK1++; TIME(); LCD_flush(); temp=year; ltoa( (long)temp,str); string2LCD(str); string2LCD("/"); temp=month; ltoa( (long)temp,str); string2LCD(str); string2LCD("/"); temp=date; ltoa( (long)temp,str); string2LCD(str); string2LCD(" "); temp=hour; ltoa( (long)temp,str); string2LCD(str); string2LCD(":"); temp=min; ltoa( (long)temp,str); string2LCD(str); asm("\tNOP"); asm("\tNOP"); } /* End of ISR */ void TIME(void) { if((year%400==0)||((year%4==0)&&(year%100!=0))) m[2]=29; temp=m[2]; if(++sec==60) { sec=0; min++; if(min==60) { min=0; hour++; if(hour==24) { hour=0; date++; if(date==m[month]+1) { date=1; month++; if(month==13) { month=1; year++; }//end of month }//end of date }//end of hour }//end of min }//end of sec }//ed of TIME()