Henrik-
Also forgot to mention that in the older I2C design I had 8 bits of inputs and 8 bits of outputs on one 2317.
This new design is all outputs - I thought it would be easier!
Not so much......
Regards,
Steve
Henrik-
Also forgot to mention that in the older I2C design I had 8 bits of inputs and 8 bits of outputs on one 2317.
This new design is all outputs - I thought it would be easier!
Not so much......
Regards,
Steve
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Sounds like what you're looking for is the DCD operator:So, perhaps something:DCD returns the decoded value of a bit number. It changes a bit number (0 - 31) into a binary number with only that bit set to 1. All other bits are set to 0.
B0 = DCD 2 ' Sets B0 to %00000100
Henrik.Code:OutBits VAR WORD GPA VAR OutBits.BYTE0 GPB VAR OutBits.BYTE1 Outbits = DCD $E
Thanks I will try that!
I have made some progress but I still need a way to get from 1 byte which will tell me which of the 16 outputs to turn on.
Current test code:
This gives me what I want - EXCEPT - for that I have to resolve 1 byte into a word and figure out how to get the pointer right........Code:OutA=$FFFE 'Initial value for word var OutA_hi=OutA.highbyte 'Splits into hibyte OutA_lo=OutA.lowbyte 'And into low byte of the word var OutA_lo.3=0 'Bit mod OutA_hi.5=0 'Another bit mod OutA_MCPReg = OLATA 'Sets up PORTA output OutA_DataOut=OutA_lo 'Sets up data to be pushed to the MCP23S17 as the low byte gosub SEND_OutA_2317 'Send it pause 10 'Wait a bit OutA_MCPReg = OLATB 'Sets up PORTB output OutA_DataOut=OutA_hi 'Sets up data to be pushed to the MCP23S17 as the hi byte gosub SEND_OutA_2317 'Send it
starting with a byte var which has a value from 0-15 to a specific bit on the MCP23S17 still evades me I am afraid.
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Henrik-
Thanks for the assist, but I don't think I can use that idea. There are some outputs which will be already active which another serial command comes in and I will need to add to the already ON LEDs with whatever new ones are called for.
There is a serial comm line coming into the project and on that serial comm is a byte which will let me know which output(s) to turn on. Some may or may not be on.
So, I will have to logically AND them to get the correct outputs on when they need to be.
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Why does this not work?
OutA.12=0 doesn't gen an error but it nor the other (OutA.15=0) turns ON an LED?????
Code:OutA=$FFFE 'Initial value for word var OutA_hi=OutA.highbyte 'Splits into hibyte OutA_lo=OutA.lowbyte 'And into low byte of the word var ' OutA_lo.3=0 'Bit mod - WORKS ' OutA_hi.5=0 'Another bit mod - WORKS OutA.12=0 'Why doesn't this work? OutA.15=0 'Or this? OutA_MCPReg = OLATA 'Sets up PORTA output OutA_DataOut=OutA_lo 'Sets up data to be pushed to the MCP23S17 as the low byte gosub SEND_OutA_2317 'Send it pause 10 'Wait a bit OutA_MCPReg = OLATB 'Sets up PORTB output OutA_DataOut=OutA_hi 'Sets up data to be pushed to the MCP23S17 as the hi byte gosub SEND_OutA_2317 'Send it
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
is a simple assignment operation not an aliasOutA_hi=OutA.highbyte 'Splits into hibyte
OutA_lo=OutA.lowbyte 'And into low byte of the word var
would fix it (get the order correct)OutA=$FFFE 'Initial value for word var
OutA.12=0
OutA.15=0
OutA_hi=OutA.highbyte 'Splits into hibyte
OutA_lo=OutA.lowbyte 'And into low byte of the word var
Thanks!
I tried your suggestion:
And it works like a CHAMP!Code:OutA=$FFFF 'Initial value for word var OutA.0=0 'Bit mod - WORKS OutA.2=0 'Another bit mod - WORKS OutA.0=0 'Bit mod - WORKS OutA.8=0 'Another bit mod - WORKS OutA.10=0 'Bit mod - WORKS OutA.12=0 'Another bit mod - WORKS OutA_hi=OutA.highbyte 'Splits into hibyte OutA_lo=OutA.lowbyte 'And into low byte of the word var OutA_MCPReg = OLATA 'Sets up PORTA output OutA_DataOut=OutA_lo 'Sets up data to be pushed to the MCP23S17 as the low byte gosub SEND_OutA_2317 'Send it pause 10 'Wait a bit OutA_MCPReg = OLATB 'Sets up PORTB output OutA_DataOut=OutA_hi 'Sets up data to be pushed to the MCP23S17 as the hi byte gosub SEND_OutA_2317 'Send it
However (you knew it might come) how do I resolve a single byte variable which tells me which bit to turn on/off into a word var?
My need for this home project, is to read a byte var and based on its value turn on/off a bit on the expander?
Example: Var=$C, so I need to turn on the 12th bit on the expander.
Regards,
Steve
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Bookmarks