Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute FlashForth word when pin changes

I have a word that I wish to trigger on pin change:

: example
  ." Hello, world! "
;i

I am using External Interrupt Request 1, which is interrupt vector no. 3 according to page 65 of the datasheet and this diagram I use.

' example 3 int!
ei

When I try to change the value of a pin (pin 3 in this case), nothing happens.

Am I doing something wrong?

like image 373
Rick Avatar asked Nov 19 '25 08:11

Rick


1 Answers

There are several things wrong with the code I posted above, but I did get it working after looking at other examples and reading the data sheet:

\ Pin Change Interrupt 0
4 constant pcint0

\ Pin Change Mask Register 0
$6b constant pcmsk0

\ Pin Change Interrupt Control Register
$68 constant pcicr

ram variable example

: example+1
  1 example +!
;i

: int-enable
  ['] example+1 pcint0 int!
  ei
;

int-enable

%00000001 pcmsk0 mset
%00000111 $68 mset

\ Shorting pin 8 will now increment `example` variable.
like image 187
Rick Avatar answered Nov 21 '25 20:11

Rick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!