Page 1 of 1

simple Interrupt for PROstart

Posted: Wed Oct 26, 2022 12:42 pm
by ctkilian
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

Re: simple Interrupt for PROstart

Posted: Wed Oct 26, 2022 7:44 pm
by basicchip
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
EINT0.bas
(2.98 KiB) Downloaded 2039 times
1114int.jpg
1114int.jpg (89.9 KiB) Viewed 29319 times

Re: simple Interrupt for PROstart

Posted: Fri Oct 28, 2022 7:01 pm
by basicchip
Updated the file to change the label to GPIO0.1 for LPC1114

Also program correctly for rising edge interrupt (default was falling edge).

Re: simple Interrupt for PROstart

Posted: Sun Oct 30, 2022 1:47 am
by ctkilian
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

Re: simple Interrupt for PROstart

Posted: Sun Oct 30, 2022 10:56 am
by basicchip
The details of these interrupts are in the NXP user manual.

To change to GPIO0.3 --

Code: Select all

INTERRUPT SUB INT_GPIO0
  GPIO0_IC = (1 << 3)			' clear interrupt on pin 3
and

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)
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

Re: simple Interrupt for PROstart

Posted: Wed Nov 02, 2022 12:17 am
by ctkilian
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

Re: simple Interrupt for PROstart

Posted: Tue Nov 08, 2022 12:49 am
by ctkilian
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