/*----------------------------*/ /* 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,voltage=1000; int temp1; void main() { stc32_init(); string2PC("\n \r Begin Test "); while ( 1 ) { while( ( cmd = rs232_in() ) == 0 ); switch ( cmd ) { case 't': disabletimer1isr(); break; case 'T': settimer1freq( 2 ); inittimer1isr(); break; }//switch end }//while end }//main end /*====================================*/ /* Begin of ISR */ /* -------------------------------------------- */ /* External Hardware Interrupt /INT2 User defined ISR -------------------------------------------- */ void c_int02() { 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++; count++; temp=count; ltoa((long)temp,str); string2PC(str); string2PC("\n\r"); set_pwm(2,voltage); if(count<=488) voltage=voltage-2; if(count>=499) { voltage=voltage+2; if(voltage==1000) { count=0; } } asm("\tNOP"); asm("\tNOP"); } /* End of ISR */