From provisional experiments it seems that it's possible to control the direction of PORTB, the standard Output Pins, on the 18X.
This allows an 18X to have up to 13 inputs and/or up to 8 bi-directional I/O lines.
It also opens the door for high-speed SPI receive and high-speed serial input. Timer1 should be configurable as a counter driven by an external pulse, and the 32kHz LP Osc may even be usable for time keeping. It should also be possible to us RB0(INT) as an edge-triggered latch to detect short pulses which polling or SETINT would miss, and RB4-RB7 can be used to flag input pin changes.
The 18X continually updates TRISB so poking that does no good, but it appears there's a shadow register at $AE(174) which is used to set TRISB. Poking $AE consequently sets TRISB.
There are a few caveats -
1) Don't come crying to me or Rev-Ed if your PICAXE catches fire or is destroyed etc.
2) Not exhaustively tested. Tested on Firmware 8.5 but may not work on others. There may be side-effects I haven't noticed.
3) HIGH, LOW, etc commands do not automatically make the applicable pin an output; $AE must be poked to change the pin direction.
4) I2CSLAVE and other commands which affect PORTB will likely overwrite and change $AE.
5) You <b>will </b> need a 330R or higher ( 1K or 10K is probably a good bet ) current limiting resistor in series with each input to prevent damage to the PICAXE.
6) Poke a 0 bit for Output, a 1 bit for Input ( Standard TRISB values, inverse of 'LET DIRSC=' ).
Example program ...<code><pre><font size=2 face='Courier'> POKE $AE,%11111111 ' All Inputs
DO
PEEK $06,b0 ' Read PORTB
SERTXD(#bit7,#bit6,#bit5,#bit4,#bit3,#bit2,#bit1,#bit0,CR,LF)
PAUSE 500
LOOP </font></pre></code>
This allows an 18X to have up to 13 inputs and/or up to 8 bi-directional I/O lines.
It also opens the door for high-speed SPI receive and high-speed serial input. Timer1 should be configurable as a counter driven by an external pulse, and the 32kHz LP Osc may even be usable for time keeping. It should also be possible to us RB0(INT) as an edge-triggered latch to detect short pulses which polling or SETINT would miss, and RB4-RB7 can be used to flag input pin changes.
The 18X continually updates TRISB so poking that does no good, but it appears there's a shadow register at $AE(174) which is used to set TRISB. Poking $AE consequently sets TRISB.
There are a few caveats -
1) Don't come crying to me or Rev-Ed if your PICAXE catches fire or is destroyed etc.
2) Not exhaustively tested. Tested on Firmware 8.5 but may not work on others. There may be side-effects I haven't noticed.
3) HIGH, LOW, etc commands do not automatically make the applicable pin an output; $AE must be poked to change the pin direction.
4) I2CSLAVE and other commands which affect PORTB will likely overwrite and change $AE.
5) You <b>will </b> need a 330R or higher ( 1K or 10K is probably a good bet ) current limiting resistor in series with each input to prevent damage to the PICAXE.
6) Poke a 0 bit for Output, a 1 bit for Input ( Standard TRISB values, inverse of 'LET DIRSC=' ).
Example program ...<code><pre><font size=2 face='Courier'> POKE $AE,%11111111 ' All Inputs
DO
PEEK $06,b0 ' Read PORTB
SERTXD(#bit7,#bit6,#bit5,#bit4,#bit3,#bit2,#bit1,#bit0,CR,LF)
PAUSE 500
LOOP </font></pre></code>