simple Interrupt for PROstart

Questions about the BASICtools and MakeItC
Post Reply
ctkilian
Posts: 9
Joined: Fri Feb 20, 2015 2:31 pm

simple Interrupt for PROstart

Post 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



basicchip
Posts: 1057
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: simple Interrupt for PROstart

Post 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 17 times
1114int.jpg
1114int.jpg (89.9 KiB) Viewed 372 times

basicchip
Posts: 1057
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: simple Interrupt for PROstart

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

ctkilian
Posts: 9
Joined: Fri Feb 20, 2015 2:31 pm

Re: simple Interrupt for PROstart

Post 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

basicchip
Posts: 1057
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: simple Interrupt for PROstart

Post 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

ctkilian
Posts: 9
Joined: Fri Feb 20, 2015 2:31 pm

Re: simple Interrupt for PROstart

Post 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

ctkilian
Posts: 9
Joined: Fri Feb 20, 2015 2:31 pm

Re: simple Interrupt for PROstart

Post 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

Post Reply