I could really use a sample program (using BASIC) of using an external interrupt on a PRO start board. Ultimately I would like to have 2 interrupting devices.
Thank you, Chris
simple Interrupt for PROstart
Re: simple Interrupt for PROstart
I will add this to the next release.
This uses the BOOT pin (GPIO0.1) which can be toggled by BASICtools. (I should change the label from EINT0 to GPIO0.1)
Source for
This uses the BOOT pin (GPIO0.1) which can be toggled by BASICtools. (I should change the label from EINT0 to GPIO0.1)
Source for
Re: simple Interrupt for PROstart
Updated the file to change the label to GPIO0.1 for LPC1114
Also program correctly for rising edge interrupt (default was falling edge).
Also program correctly for rising edge interrupt (default was falling edge).
Re: simple Interrupt for PROstart
Thanks, the example works, but I can't figure out how to modify the example for an external interrupt coming in on, say, P0.3.
Chris
Chris
Re: simple Interrupt for PROstart
The details of these interrupts are in the NXP user manual.
To change to GPIO0.3 --
and
And if you need multiple pins on GPIO0, add those bits to the above, and then test for which one in GPIO0_MIS and clearing just that one in the interrupt routine
To change to GPIO0.3 --
Code: Select all
INTERRUPT SUB INT_GPIO0
GPIO0_IC = (1 << 3) ' clear interrupt on pin 3
Code: Select all
SUB ON_GPIO0(rise_edge, dothis)
' Setup MUST be done before enabling the interrupt
GPIO0_IE = (1 << 3) ' interrupt on GPIO0.3
if rise_edge then GPIO0_IEV = (1 << 3)
Re: simple Interrupt for PROstart
Thanks again, I got it to work on P0.3, although I had to "comment out" 2 lines that I thought you said should be there (see below). Chris
'LPC1114Int_tst3 this test routine demonstrates using an external interrupt on P0.3
#if defined(LPC1114)
#define INT_STR "GPIO0.1"
#endif
dim e0 as integer
dim s0 as integer
dim rx as integer
INTERRUPT SUB INT_GPIO0_1
GPIO0_IC = (1<<3) ' clear interrupt
e0 = e0 + 1
ENDSUB
SUB ON_GPIO0_1(rise_edge, dothis)
' Setup MUST be done before enabling the interrupt
GPIO0_IE = (1<<3) ' interrupt on GPIO0.3
'GPIO0.3
'if rise_edge then GPIO0_EV = (1<<3)
GPIO0_ISR = dothis or 1 'set function of NVIC
VICIntEnable = VICIntEnable or (1<<31) '&H80000000 'Enable interrupt Vector 31 -GPIO0
ENDSUB
'LPC1114Int_tst3 this test routine demonstrates using an external interrupt on P0.3
#if defined(LPC1114)
#define INT_STR "GPIO0.1"
#endif
dim e0 as integer
dim s0 as integer
dim rx as integer
INTERRUPT SUB INT_GPIO0_1
GPIO0_IC = (1<<3) ' clear interrupt
e0 = e0 + 1
ENDSUB
SUB ON_GPIO0_1(rise_edge, dothis)
' Setup MUST be done before enabling the interrupt
GPIO0_IE = (1<<3) ' interrupt on GPIO0.3
'GPIO0.3
'if rise_edge then GPIO0_EV = (1<<3)
GPIO0_ISR = dothis or 1 'set function of NVIC
VICIntEnable = VICIntEnable or (1<<31) '&H80000000 'Enable interrupt Vector 31 -GPIO0
ENDSUB
Re: simple Interrupt for PROstart
on further examination it turns out that the line
if rise_edge then GPIO0_IEV = (1<<3)
must be included to make the interrupt happen on the rising edge (otherwise it happens on the falling edge)
Chris
if rise_edge then GPIO0_IEV = (1<<3)
must be included to make the interrupt happen on the rising edge (otherwise it happens on the falling edge)
Chris