Henrik-
I may have been too hasty in my description ( I am back on my home project) as I am stumped. I had used the I2C version of this part a while back and have it working. Now I am trying to use the SPI version (MCP23S17) for its speed and I can't seem to figure out how to get from a byte indicating which bit to turn on for the MCP23S17 part.
Lets say I receive a var and it's value is $E. This var needs to tell the MCP23S17 that the 15th output should turn on. Now that is GPB-7 on the MCP23S17.
I have a routine that converts HEX to DECIMAL (thanks to this forum years ago) and that works fine, how to I get a single decimal to go to the correct port on the MCP23S17?
My code works fine to send a binary string (easier to visualize for me) to the MCP23S17 but I can't seem to get the finesse of going from 1 hex or 1 dec char to the right bit output.
I have looked through the forum and I have seen yours and others pointing to OUT.0[var] which gets to the VAR-position of the OUT variable but as I have 2 eight bit outputs I am stumped......

From the MCP23S17 datasheet it looks like it may be addressed as one 16 bit output, is that accurate? Any suggestions?
Some code below:
Code:
OutA var byte

OUTtest:'------------ TEST
                      OutA=$1                                                  'Simulate number from serial comm, example '1'
                      K=OutA                                                   'Sets up the conversion from hex to decimal
                      gosub H2D                                               'Performs the conversion
                      debug "After H2D K=",dec1 K,13               'Double-check what the sub did
                      k=k-8                                                        'try this for a pointer
                      OutA_DataOut=OutA.0[k]                        'Try to set the correct bit out of 8 to turn on and pass to OutA_DataOut which is passed to the MCB23S17
                        OutA_MCPReg = OLATA                             'Sets up PORTA output
'                        OutA_DataOut=%11111110                    'This works by setting individual bits, but not good for what I want to do
                        gosub SEND_OutA_2317                         'Send to the expander
                        pause 10                                               'wait a bit
                        OutA_MCPReg = OLATB                             'Sets up PORTB output
                        OutA_DataOut=%01111111
                        gosub SEND_OutA_2317