PDA

View Full Version : Need help with MCP23S08



nukte
- 27th July 2008, 00:46
It's killing me and I've become obsessed but I can't get the !@#$ thing to work
I've got 8 leds connected to the outputs, and can see things being sent on the scope, and tried changing things around but still nothing. Maybe you might see it.
I've attached the code as a text file to this note
Thanks

Darrel Taylor
- 27th July 2008, 07:15
A couple of things ....

Don't REV (reverse) the bit order, both the MSSP and MCP23S08 use MSB first transfers.

And, the CS (chip select) should be taken low before each command, then made high again when the command is complete. Otherwise it thinks you're next command is consecutive bytes to the first one.
<br>

nukte
- 28th July 2008, 04:15
Thank you for your suggestion. I will change the code tomorrow and I will post the results.
Had a thought i should be deselecting with each new command, but thought Microchip might have accounted for that. Also, I was reversing the bit order because I thought (incorrectly) the SSPBUF sent out the bits in reverse.
So glad I joined this community of experts
Nukte

nukte
- 29th July 2008, 03:30
Hi Darrel
Your suggestion worked just right, and now the LEDS's light up just as I thought (hoped) they would. So thanks ever so much for the help.
Just one more item if you can. I actually have 4 of the 23so8 chips and 32 LED's. The 23s08's have a common chip select line, all tied to my pic output port at RA1. I have set each of the addresses for each 23s08 from 00 to 11, but all of the LED's are coming on at the same time. I tried changing the addresses in my code but that did not change the problem. What do you think I can do now?
Thanks Nukte

Darrel Taylor
- 29th July 2008, 03:51
Hi Darrel
Your suggestion worked just right, and now the LEDS's light up just as I thought (hoped) they would. So thanks ever so much for the help.

Great! One step down.

For step 2, you'll just need to set the HAEN bit (bit3), in the IOCON register (address 5). Which enables the Hardware Address pins. Without it, all chips respond to address 00.

hth,

nukte
- 31st July 2008, 01:37
Project working .. Nuke is happy now
Had the right code for setting HAEN but I was sending it to the wrong address.
Thank you very much This helps me alot

Christopher4187
- 16th March 2013, 18:28
Only one thread on the 23S08. Well, maybe someone can help.

I believe my problem is in the hardware but if someone can check the command below, that would be great. I took the attached file in the first thread and believe only the write command needed to be changed. I modified it to this but I still get nothing out of the 23S08. I'm using the PICkit serial SPI board.

MCP_WRITE:
low CS
SSPBUF=0
GOSUB CLOCK_BIT
SSPBUF = spout
high CS
return

I feel like something is missing in there. Also, to rule out the board, I was toggling one pin at a time. When I toggle the MOSI or MISO pins, the both appear to be connected because both pins go high and low at the same time. In other words, I pulse the MOSI with a 2 Hz signal and the MISO pin appears to be in parallel.

Confused....

Darrel Taylor
- 16th March 2013, 20:51
After loading SSPBUF the second time, you need to wait for it to finish the transfer before taking CS high again.

Christopher4187
- 16th March 2013, 23:09
No dice. I think that command was wrong and this one *looks* correct after doing some more reading.

MCP_WRITE:
low CS
SSPBUF=64
GOSUB CLOCK_BIT
SSPBUF=MCP_ADDRESS
GOSUB CLOCK_BIT
SSPBUF = MCP_DATA
GOSUB CLOCK_BIT
high CS
return
Maybe one of the IC's on the PICkit board is bad. I wouldn't expect, although I don't know for sure, the MOSI and MISO pins to both go high or low at the same time if you only have power on one of those pins.

gadelhas
- 17th March 2013, 02:16
Hi Christopher;

Check this wiki article. It shows how to handle the MCP23S17. Maybe can help you if you adapt to your ic.
http://www.picbasic.co.uk/forum/content.php?r=471-MCP23S17-Three-different-approaches-ShiftIn-ShiftOut-MSSP-PBP-MSSP-ASM

Larrystein
- 6th February 2014, 14:46
I would love to know why this info on the mcp23s08 is not in the data sheet or the application notes from the manufacturer?

It has taken me a week of on-off searching to answer this question.

Thanks to all.

MarkEngineer
- 26th February 2015, 21:20
I am having a very strange problem with the Microchip MCP23S08.
It seems no matter what I do, bit #6, GP6 is ALWAYS an input.
I send 0 to the IODIR register to make all 8 bits to be outputs.
I can output to any output except GP6.

X1 VAR BYTE
MCPWRT = $40
MCPREAD = $41

MCP23S08_IODIR = 0
SHIFTOUT SDO2, SCK2, MSBFIRST, [MCPWRT,MCP23S08_IODIR,0]

if I read back the IODIR register
SHIFTOUT SDO2, SCK2, MSBFIRST, [MCPREAD,MCP23S08_IODIR]
SHIFTIN SDI2, SCK2, MSBPRE, [X1]

X1 always comes back and hex 40 indication GP6 is an input

Help!

MarkEngineer
- 27th February 2015, 18:17
scratch that, the problem was I erroneously has another device also chip selected on the bus.