Interrupts on 28X1 & 14M chips.?

Craftybytes

Senior Member
Am still having difficulties in understanding the relevant 'code' steps to get "interrupts" working on both the 28X1 chip and 14M chip..

What I'm trying to workout is how to setup for 'interrupts' on a 14M chip with 8x 'digital' i/p lines that can output an 'interrupt' to the 28X1 chip when any of the inputs change state - more like a "programmable interrupt controller - but using a 14M chip..!!

On the 14M chip there will also be a separate i/o pin linked to the 28X1 for bi-directional data i/o - mainly for the 14M to indicate which of its input lines 'changed state' and in which direction this 'change' occurred.

I have not yet coded up for this - only at the 'flow chart' concept stage - but wondered if any picaxe users out there have ever done something like this with any of the picaxe chips..?

Any help and comments would be much appreciated..

crafty.
.
 

westaust55

Moderator
PICAXE Interrupts

Crafty,

If I read correctly, you are trying to achieve something along these lines:

If Input 0 = HIGH or Input 1 = HIGH or Input 2 = HIGH then . . . . .

But unfortunately, the PICAXE Interrupt comamnd works ONLY with one predefined configuration using a specified numper of input pins and an AND construct, akin to:

If Input 0 = HIGH and Input 1 = HIGH and Input 2 = LOW then . . . . .
 

hippy

Ex-Staff (retired)
Code:
b1 = pins
Do
  b0 = pins
  If b0 <> b1 Then
    Gosub GenerateInterrupt
    b1 = b0
  End If  
Loop
In Generate Interrupt b0^b1 will give a high for all pins which changed state, b0^b1&b0 will give a bit mask of all those which went high.
 
Last edited:

inglewoodpete

Senior Member
The 28X1 and 40X1 can handle the logical OR of inputs. The 14M is more limited, a WA55 suggests, above.

I use the following commands to detect a 'low' on either of 2 keypad inputs to a 40X1:

Code:
   Symbol KBDIntState  = %10000100     'Inputs 2 or 7: Interrupt on low input
   Symbol KBDBothPins  = %10000100     'Inputs 2 and 7 40X1 can interrupt on either pin

....and later in the code:

   SetInt Not KBDIntState, KBDBothPins   'Enable the keypad
 

kevrus

New Member
Do the inputs all need go to seperate 14m pins? If not then they can all connect to one I/P pin, each of the 8 lines having a series diode, then the interrupt can be triggered if any one of the 8 lines goes high

Code:
 setint %00000001,%00000001    'interrupt on pin 0 going high

'main code here

interrupt:
interrupt routine here 
setint %00000001,%00000001    'sets up interrupt again before returning to main program
return
 

Craftybytes

Senior Member
Thanks all for the info..

Have actually got the 28X1 part working fine - just thought I'd investigate the possible use of the 14M chip to offload some of the 'digital' input side - and free up a few extra i/o pins on the 28X1..

I could use an I2C 8 bit i/o expander module to probably do the same - but not yet fully ofey with coding for I2C at the mo..

Looks like I'll just have to stick with using the 28X1 to do what I want..

Much appreciated..

crafty.
.
 

westaust55

Moderator
Crafty,

Really nothing to complex about i2c devices.

I have used the PCF8574 i2c 8-bit-IO expanders, mainly as outputs but they are easy to interface with. These are only slow speed i2c comms devices.

wrt the INT signal, using the PCF8574 an interrupt is generated by any rising or falling edge of the port inputs in the input mode.
So any change of state on one of the pins will generate an interrupt.

BCJKiwi has been using the MCP23016/17 type which are capable of 400kHz. A little more complex but can be sued as one 16 bit port or 2 x 8 bit ports. While I have looked at the datasheet for these, have not used them but BCJ could likely assist you if need be.
 

stocky

Senior Member
Crafty,

Really nothing to complex about i2c devices.

I have used the PCF8574 i2c 8-bit-IO expanders, mainly as outputs but they are easy to interface with. These are only slow speed i2c comms devices.

wrt the INT signal, using the PCF8574 an interrupt is generated by any rising or falling edge of the port inputs in the input mode.
So any change of state on one of the pins will generate an interrupt.

BCJKiwi has been using the MCP23016/17 type which are capable of 400kHz. A little more complex but can be sued as one 16 bit port or 2 x 8 bit ports. While I have looked at the datasheet for these, have not used them but BCJ could likely assist you if need be.
This is what i do when i need an INT from any of many inputs - very handy and quite quick enough for what i want - also the INT STAYS until the chip is read - so if you jump to your INT routine and do whatever then reset your INT - bingo it trips again and you go read the new INT.

I use them as INPUT only, OUTPUT only or mixes of both - ie read 4 switches and output 4 leds with 3 pins AND Interrupt capabilities on the 4 switches as well!

Current design I'm working on isrunning 3 PCF8574 - one on 8 way dip switch, one on 8 leds and another running 8 digital inputs with interrupts.
About to do another one that will test my coding - going to use PCF8475 & 8574A - up to max 8 of each for a large scale IO system running over UHF commerical band 25w data transmitter! 128 i/o - max 64 in AND 64 out and just 3 PICAXE pins!
 
Last edited:

Craftybytes

Senior Member
Duh - slaps forehead as the old brainbox flips on..

I've actually got an I2C-16IO module which is based on the PCA9535 IC (smd) on hand - provides 16 programmable I/O pins - 400kHz I2C speed - plus 'interrupt' output..

So maybe for my project I'll look at this module for possible i/o expansion to the 28X1 chip..

Thanks for the heads up..

crafty.
.
 
Top