problems coding for MCP23016 expansion chip
Fellow SXers;
Some questions and code for you to look at...
I have been working on the SX/28 and some I2C chips. (So far: 24LC64 memory, DS1621 temp; and now MCP23016 expander) on the PDB board. Display is to a 2 Digit 7 segment LCD using RB and RC outputs. The display, temperature and memory have all been working and my latest addition is the expander chip. I now get compiler warnings & error
1) warning 37, pass 2: literal truncated to 8 bits
·· line MOV# __PARAM1,#wr23016··· ;I2CSEND, wr23016
2) error 43, pass 2: address exceeds memory limit
· .. I have tried commenting out portions of code..eg MEM_IN.. but still fall short
·Is item 1 important?
·Does item 2 mean my program is too big...and what to do about it?
·How does the setup code and then EXP_IN, EXP_OUT code look for the MCP23016?
·Thanks, John
Some questions and code for you to look at...
I have been working on the SX/28 and some I2C chips. (So far: 24LC64 memory, DS1621 temp; and now MCP23016 expander) on the PDB board. Display is to a 2 Digit 7 segment LCD using RB and RC outputs. The display, temperature and memory have all been working and my latest addition is the expander chip. I now get compiler warnings & error
1) warning 37, pass 2: literal truncated to 8 bits
·· line MOV# __PARAM1,#wr23016··· ;I2CSEND, wr23016
2) error 43, pass 2: address exceeds memory limit
· .. I have tried commenting out portions of code..eg MEM_IN.. but still fall short
·Is item 1 important?
·Does item 2 mean my program is too big...and what to do about it?
·How does the setup code and then EXP_IN, EXP_OUT code look for the MCP23016?
·Thanks, John
SXB
![](/plugins/FileUpload/images/file.png)
9K
Comments
DevType CON $0100 << 4 'Device type
Should be:
DevType CON %0100 << 4 'Device type
Note a "%" instead of a "$"
Even if you do fix this line, you are still out of code space. Use the techniques that Jon has suggested. Then you will have lots of code space left.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My goal is to live forever...Or die trying.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
I fixed the error above and stripped the program down to MCP23016 only code...
no more memory error. I will address Jon's suggestion to encapsulate code
in subroutines to avoid too much inline stuff.. later.
The lateset program is attached in file EXP1I2.SXB. It doesn't put anything
out on the display yet.. if I get a high on GP0.x it should work since doing
it manually with a wire..lights up a segment on the display.
I have some concern over the exterior capacitor 33 pf· and resistor 3.9k.
The resistor is spot on but I'm uncertain of the capacitor value is is identified
with ( green 102M 1KV 250) .. I'm thinking it might be 250 pf. Meter says 2.1 nF..but
I'm not sure if it goes down that far. It may be another day or 2 before I can try
to get 33 pf at RadioShack. In the mean time do you think this one would work?
Any comments on latest source would also be appreciated..
·EXP_OUT:
· tmpB1 = __PARAM1··' digit to display
· I2CSTART SDA
· I2CSEND SDA, Wr23016··' send to who
· 'I2CSEND SDA, GP0··' info for register·· .. would not compile, replace below
· I2CSEND SDA, $00··' info for register
· I2CSEND SDA, tmpB1··' the data to send
· I2CSTOP SDA
· PAUSE 100
· RETURN
'I2CIN SDA, Rd23016, GP1, butCtrl
·EXP_IN:
· I2CSTART SDA
· I2CSEND SDA, Wr23016··' send to who
· I2CSEND SDA, GP1··' info for register
· I2CSTART SDA
· I2CSEND SDA, Rd23016··' receive from who
· I2CRECV SDA, tmpB2, Nak·' receive byte
· I2CSTOP SDA
· PAUSE 100
· RETURN tmpB2
Thanks, John
10 followed by two zeros, pF --> 1000 pF ("1nF")
Unfortunately, program still not working.
Had wiring error mixup pin 19 vs 18... circuit now diplaying on 2 LED's, one direct from SX/28 the other thru MCP23016.
Currently have 1 question:
1) I currently have code to increment a counter:· from 1 to 16 but it doesn't seem to work. What is wrong?
·· IF countB = 16 THEN
······ countB = 0
······ ELSE
······ countB = countB + 1
······ ENDIF
One other question... is there some way to speed up the program download ..it currently takes me about 30 seconds.