#include #include #include #include "v25.h" /*v25¿ë Header File */ #define YES 1 #define NO 0 void delay_10(void) { int i, j; for (i =0 ; i < 12; i++) for(j = 0; j < 5000; j++) ; } volatile int interval_flag; /* Variable changed by ISR */ volatile int brightness; /* -> always read real-memory, not in register */ void bright_control(void) { int i, tmp; printf("\nPress Any Key to Stop "); interval_flag=NO; for (i = 0; i < 200; i++) { /* Wait Another Timer Period */ while(interval_flag != YES) ; disable(); /* Disable Interrupt */ interval_flag = NO; tmp = brightness; brightness = i / 20; if (tmp != brightness) printf("\n Brightness = %d", brightness); enable(); /* Enable Interrupt */ if (kbhit()) { getch(); break; } } } void interrupt new_int1Ch(void) { /* TURBO_C does complex interrupt stuffs */ static int timer_count = 0; enable(); /* Enable Higher Priority Interrupt */ timer_count++; if (timer_count >= 10) { timer_count = 0; interval_flag = YES; } if (timer_count < brightness) pokeb(V25_IRAM,V25_P0,0x00); else pokeb(V25_IRAM,V25_P0,0xFF); } void main(void) { void interrupt (*old_int1Ch)(); /* Old Interrupt ISR */ pokeb(V25_IRAM, V25_PMC0, 0x0); /* V25 port 0 => OUTPUT */ pokeb(V25_IRAM, V25_PM0, 0x0); old_int1Ch = getvect(0x1C); /* Save Original ISR */ setvect(0x1C,new_int1Ch); /* Set New Vector */ bright_control(); setvect(0x1C,old_int1Ch); /* Restore Origianl Vector */ printf("\nLED "); printf("ON "); pokeb(V25_IRAM, V25_P0, 0x00); delay_10(); printf("OFF "); pokeb(V25_IRAM, V25_P0, 0xFF); delay_10(); printf("ON "); pokeb(V25_IRAM, V25_P0, 0x00); delay_10(); printf("\n"); }