I ordered a couple of samples of the DIP version...I'm in no hurry, but I did wonder why they're shipping from Thailand!· You'd think there'd be a distributor Stateside...I've never sampled from Microchip before, as they've never had anything I was interested in designing around.· I had quite a relationship with National for awhile, as I was designing alot of things around their chips, and generating some sales for them...However, they discontinued my favorite chips, and I haven't worked with them much either.· Maxim/Dallas has been my friend for awhile.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Chris Savage
Knight Designs 324 West Main Street P.O. Box 97 Montour Falls, NY 14865 (607) 535-6777
I just got my 3 sample chips in...PDIP version...This is a loooong chip, kinda like the MAX7219.· Anyway Sid, so I am set.· Plus National sent me some samples of a new Amplifier chip, although without the other support chips I used to use from them being available, I will have to put serious thought into any new amplifier designs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Chris Savage
Knight Designs 324 West Main Street P.O. Box 97 Montour Falls, NY 14865 (607) 535-6777
You could do that, or you could make the slave address a variable. For example, you could have a variable called device (a NIB will do) that would determine which unit you want to talk to. Then you could do this:
Since I2C sends 8-bit chunks at a time, whether it goes out MSB first or LSB first is irrelevant -- it's the connections that matter when dealing with an IO port like the MCP23016. If you send %10000000 to GP0, then GP0.7 should go high (if you configured GP0.7 as an output port). Register IODIR0 sets the IO bits for GP0. Keep in mind that the MCP23016 uses "1" for an input, and "0" for an output (think of the numbers looking like "i" for IN, and "o" for OUT) -- this is opposite of the BASIC Stamp.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams
Applications Engineer, Parallax
Dallas Office
All understood.· The first bit of %1000000 goes to GPx.7.· I think this is backwards to a 595 shift register.· If you shiftout %10000000 MSBFIRST to a 595, the first bit goes to pin 1.· Right?
I'm not sure (how the '595 interals are setup) -- you'd have to connect a circuit and give it a run.· The difference between SHIFTOUT and I2COUT is that with SHIFTOUT you can control the bits sent.· When you connect your '595 circuit, try this:
I think I was in error when I said the 595 worked backwards to the MCP23016.· I looked at the logic diagram in the 595 data sheet and it appears that the first bit is clocked into Qa, then on the following clock pulse, on the rising edge the bit in the Qa· gets shifted into Qb, and the second bit is clocked into Qa on the falling edge of the clock pulse.
This process continues until all 8 bits have been clocked in. So, if you
sent %10000000 MSBFIRST, the " 1 " winds up at Pin 7, Qh.
Well, now we have that straightened out.· It works just like the MCP23016.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Sid Weaver
Try the Stamp Tester
I've been using the MCP23016 to drive LEDs and read jumper settings. I got it to work with a BS2pe, but needed a little more speed and tried the same source code with a BS2p (vers 1.2). I changed the Baud constants and I don't use any other chip dependent timing (just PAUSE). It didn't work. After a lot of debugging, I determined that the MCP23016 wasn't even being initialized and that the I2C commands did not seem to be working properly. I took Jon's code for doing I2C with a BS2, substituted that for my existing I2C commands and it worked. Why? I'd much rather use the built-in commands.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Visit the Piggyback Page
http://hometown.aol.com/newzed/index.html
·
SETUP:
· PAUSE 100
· I2COUT SDA, Wr23016, IODIR0, [noparse][[/noparse]%00000000]
· I2COUT SDA, Wr23016, IODIR1, [noparse][[/noparse]%00000000]·····
I·have three MCPs.· I want to set DevAddr1 as inputs and DevAddr2 and DevAddr3 as outputs.· How do I change the above lines?
Thanks.
Sid
For instance,· WrMCP1 con %01000100
·················· WrMCP2 con %01000010
· ·················WrMCP3 con %01001000
and do the same for Rd23016?
Sid
slvAddr = %01000000 | (device << 1)
I2COUT SDA, slvAddr, register, [noparse][[/noparse]value, ...]
You can use the same slave address for I2OUT and I2CIN -- the BASIC Stamp takes care of the write/read bit of the slave address.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
So if I write:
I2COUT....[noparse][[/noparse]%10000000]
the "1" gets shifted out first and whatever is tied to GPx.0 will be taken high.· Is that correct?
Following this reasoning, if I read the states of GPx and receive
%10000000, then whatever is connected to GPx.0 is high.· Is this also correct?
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Sid
Correction:· Pin 15, not pin 1.
Post Edited (Newzed) : 9/23/2004 10:53:48 PM GMT
Test:
· FOR idx = 1 TO 8
··· SHIFTOUT DPin, Clock, MSBFIRST, [noparse][[/noparse]0]····
··· PULSOUT Latch, 3
··· SHIFTOUT DPin, Clock, MSBFIRST, [noparse][[/noparse]%11111111\idx]····
··· PULSOUT Latch, 3
··· PAUSE 1000
· NEXT
The first SHIFTOUT clears the outputs, the second tests the way things are actually going from the [noparse][[/noparse]serial]·input to the outputs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
This process continues until all 8 bits have been clocked in. So, if you
sent %10000000 MSBFIRST, the " 1 " winds up at Pin 7, Qh.
Well, now we have that straightened out.· It works just like the MCP23016.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Try the Stamp Tester
http://hometown.aol.com/newzed/index.html
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office