/*----------------------------*/ /* Include Header File */ /*----------------------------*/ #include "stc32.h" /* stc32 register address define and function prototype*/ #include "math.h" /*-------------------------------------*/ /* System's 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 temp1; /*-----------------------------------*/ /* User's Global variable definition */ /*-----------------------------------*/ int speed=500,voltage=1000,count=0; void main() { stc32_init(); string2PC("\n \r Begin Test "); while ( 1 ) { while( ( cmd = rs232_in() ) == 0 ); rs232_out( cmd ); switch ( cmd ) { case 'l': case 'L': settimer1freq(20); inittimer1isr(); break; } /* switch */ } /* while */ }//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++; if(count<=800) { if(flag==0) { set_dac_cmd(0,5.0); flag=1; /* temp=count; ltoa( (long)temp,str); string2PC(str); string2PC("\n\r");*/ } else { set_dac_cmd(0,0.0); flag=0; temp=count/2; ltoa( (long)temp,str); string2PC(str); string2PC("\n\r"); } } else disabletimer1isr(); asm("\tNOP"); asm("\tNOP"); } /* End of ISR */