/*----------------------------------------------------------------------------*/ /** * Demo program for gtuc51 (with io board) **/ /*----------------------------------------------------------------------------*/ #include "adc0831.h" #include "keypad_922.h" #include "textlcd.h" #include "utils_float.h" /*----------------------------------------------------------------------------*/ /** * Switch & LED Interface for gtuc51 i/o board * - multiplexed (dual/purpose) * - require jumper link settings! **/ /** SW0, SW1 => P3.3, P3.2 - LAYOUT ERROR */ __sbit __at (0xB3) SW0; __sbit __at (0xB2) SW1; /** LED{0-3} => P3.4-P3.7 */ __sbit __at (0xB4) LED0; __sbit __at (0xB5) LED1; __sbit __at (0xB6) LED2; __sbit __at (0xB7) LED3; /** LED{RX,TX} => P3.1, P3.0 - LAYOUT ERROR */ __sbit __at (0xB1) LEDRX; __sbit __at (0xB0) LEDTX; /** alias LEDX=-2 and LEDY=-1 (LEFT OF LED0) **/ __sbit __at (0xB1) LEDX; __sbit __at (0xB0) LEDY; /*----------------------------------------------------------------------------*/ char display[LCD_MAX_CHAR]; unsigned char lcdi, loop; float value; keybyte_t keyin; adcbyte_t check; __bit adc, adcgo, left, demo; /*----------------------------------------------------------------------------*/ #define DEMO_IO 1 #define DEMO_ADC 0 /*----------------------------------------------------------------------------*/ #define LOOP_COUNT 20 /*----------------------------------------------------------------------------*/ /* interrupt service routine for timer0 */ void timer_blink(void) __interrupt TF0_VECTOR { TR0 = 0; loop--; P1 = ~P1; if (loop==0) { if (!left) { loop = LED0; LED0 = LED1; LED1 = LED2; LED2 = LED3; LED3 = LEDX; LEDX = LEDY; LEDY = loop; } else { loop = LED3; LED3 = LED2; LED2 = LED1; LED1 = LED0; LED0 = LEDY; LEDY = LEDX; LEDX = loop; } loop = LOOP_COUNT; } TH0 = 0x4B; TL0 = 0xFD; TR0 = 1; /** 50ms */ } /*----------------------------------------------------------------------------*/ /* interrupt service routine for timer1 */ void timer_goadc(void) __interrupt TF1_VECTOR { TR1 = 0; TH1 = 0x4B; TL1 = 0xFD; if (loop>0) { TR1 = 1; /** 50ms */ loop--; } else { loop = LOOP_COUNT; adcgo = adc; } } /*----------------------------------------------------------------------------*/ /* interrupt service routine for int1 */ void check_switch0(void) __interrupt IE1_VECTOR { left = 0; if (lcdi