00001
00002
00003
00004
00005
00006 #include "piccolo_all.h"
00007
00025 volatile int counter;
00026 volatile char c;
00027
00028
00029
00031 #pragma interrupt hi_isr
00032 void hi_isr() {
00033 USBDeviceTasks();
00034 }
00036 #pragma interruptlow lo_isr
00037 void lo_isr() {
00038 #if defined(__18F4550)
00039 c=PORTB;
00040 INTCONbits.RBIF=0;
00041 #elif defined(__18F14K50)
00042 c=PORTA;
00043 INTCONbits.RABIF=0;
00044 #endif
00045 counter++;
00046 }
00047
00048
00049
00050 void main(void) {
00051 unsigned int my_counts;
00052 InitializeSystem();
00053 RCONbits.IPEN=1;
00054 INTCONbits.GIEL=1;
00055
00056 while (!usb_cdc_kbhit()) {
00057 ProcessIO();
00058 }
00059 outString("bounce_test.c program, ");
00060
00061 #if defined(__18F4550)
00062 TRISB=0xFF;
00063 INTCON2bits.RBPU=0;
00064 c = PORTB;
00065 INTCONbits.RBIF=0;
00066 INTCON2bits.RBIP=0;
00067 INTCONbits.RBIE=1;
00068 outString("PICCOLO-4550\n");
00069 #elif defined(__18F14K50)
00070 IOCAbits.IOCA3=1;
00071 c = PORTA;
00072 INTCONbits.RABIF=0;
00073 INTCON2bits.RABIP=0;
00074 INTCONbits.RABIE=1;
00075 outString("PICCOLO-14K50\n");
00076 #endif
00077 while (1) {
00078 outString("Nyomja le és engedje fel SW1-et! ... ");
00079 counter = 0;
00080 while(SW1==1) ProcessIO();
00081 delay_ms(20);
00082 while(SW1==0) ProcessIO();
00083 delay_ms(20);
00084 my_counts=counter;
00085 out4hex(my_counts);
00086 outString(" megszakítás volt, SW1 ");
00087 if(my_counts<3) outString("nem ");
00088 outString("pergett\n");
00089 }
00090 }