' Test EINT0 on (P2.10) ' For SuperPRO/PROplus ' For ARMmite or PRO-with-Coridium-USB dongle ' ' and GPIO0.1 for LPC1114 -- ProStart ' ' BASICtools / Options / test / toggle BOOT will toggle EINT0 ' ' triggering an EINT0 interrupt #if defined(LPC1756) || defined(LPC1751) #define INT_STR "EINT0" #elif defined(LPC2103) || defined(LPC2138) #define INT_STR "EINT0" #elif defined(LPC1114) #define INT_STR "GPIO0.1" #else #error -- code not ported to this CPU #endif dim e0 as integer dim s0 as integer dim rx as integer #if defined(LPC1114) INTERRUPT SUB INT_GPIO0_1 GPIO0_IC = 2 ' clear interrupt e0 = e0 + 1 ENDSUB #else INTERRUPT SUB EINT0IRQ SCB_EXTINT = 1 ' Clear interrupt #if defined(LPC2103) || defined(LPC2138) VICVectAddr = 0 ' Acknowledge Interrupt #endif e0 = e0 + 1 ENDSUB #endif #if defined(LPC1756) || defined(LPC1751) SUB ON_EINT0(rise_edge, dothis) PCB_PINSEL4 = (PCB_PINSEL4 and &Hffcfffff) or &H00100000 ' EINT0 on P2.10 SCB_EXTMODE = SCB_EXTMODE or 1 ' Enable edge mode SCB_EXTINT = 1 ' Clear interrupt if rise_edge SCB_EXTPOLAR = SCB_EXTPOLAR or 1 ' trigger on rise edge else SCB_EXTPOLAR = SCB_EXTPOLAR & &HFFFFFFFE ' trigger on fall edge (default) endif EINT0_ISR = dothis or 1 'set function of VIC VICIntEnable = VICIntEnable or (1<<18) '&H00040000 'Enable interrupt Vector 18 ENDSUB #elif defined(LPC2103) || defined(LPC2138) SUB ON_EINT0(rise_edge, dothis) ' Setup MUST be done before enabling the interrupt PCB_PINSEL1 = PCB_PINSEL1 or psfEINT0 ' select pin function SCB_EXTINT = 1 ' clear interrupt SCB_EXTMODE = SCB_EXTMODE or 1 ' enable edge mode if rise_edge SCB_EXTPOLAR = SCB_EXTPOLAR or 1 ' trigger on rise edge else SCB_EXTPOLAR = SCB_EXTPOLAR & &HFFFFFFFE ' trigger on fall edge (default) endif VICVectAddr4 = dothis ' set function of VIC 4 VICVectCntl4 = &H2e ' use it for EINT0 Interrupt: VICIntEnable = &H4000 ' enable EINT0 Interrupt: VICVectAddr = 0 ' Acknowledge all Interrupts ENDSUB #elif defined(LPC1114) SUB ON_GPIO0_1(rise_edge, dothis) ' Setup MUST be done before enabling the interrupt GPIO0_IE = 2 ' interrupt on GPIO0.1 GPIO0_ISR = dothis or 1 'set function of NVIC VICIntEnable = VICIntEnable or (1<<31) '&H80000000 'Enable interrupt Vector 31 -GPIO0 ENDSUB #endif main: print INT_STR;" Interrupt Test" print "BASICtools / Options / test / toggle BOOT will toggle ";INT_STR #if defined(LPC1114) ON_GPIO0_1(1, ADDRESSOF INT_GPIO0_1) 'set up for rising edge #else ' LPC175x LPX21xx VIC_VTOR = VIC_VTOR or &H20000000 ON_EINT0(1, ADDRESSOF EINT0IRQ) 'set up for rising edge #endif e0 = 0 s0 = 0 rx = 0 WHILE (1) if s0 <> e0 then s0 = e0 print "Received ";INT_STR endif LOOP