Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8597

C/C++ • Re: Can't get MCP23017 Inputs working consistently with C

$
0
0
Thanks, there is a lot to read and I'll start it tonight. Hopefully this solves my issue.

Just curious, what is the advantages to kernel drivers over ioctl calls?
just working ... As your approach seems non-working

I've been reading through everything I can find in the forums on the MCP23017 and dtoverlays and device trees and there is definitely a lot to digest. I want to start off by stating I hate asking questions on things that I feel I should be able to figure out myself but after weeks of reading and trying stuff, I'm feeling a little frustrated so here it goes. Sorry if these questions seem stupid but I can't seem to resolve a few things and may be going down the wrong path. It's not that there is conflicting info but it is somewhat unclear for those of us new to it.

I have 3 MCP23017s on one RPi 4B (2 outputting and one inputting) communicating with 3 on another RPi 4B.
sudo i2cdetect -y 1yields

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 21 22 -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --                       

Adding dtoverlay=mcp23017to /boot/config.txt yielded the correct response

    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: UU 21 22 -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --     
                 
I thought adding the following would allow control of 0x21 also

dtoverlay=mcp23017, i2c-path=i2c@0
dtoverlay=mcp23017, i2c-path=i2c@1

But it doesn't. What am I not understanding? Obviously I'm not linking this to the second i2c.

Next question. I couldn't figure out if the MCP23017 overlay is actually part of the kernel now that just needed to be turned on in /boot/config.txt or if I had to create and compile an overlay to add in.

Statistics: Posted by gjm27n — Sun Feb 02, 2025 7:02 pm



Viewing all articles
Browse latest Browse all 8597

Trending Articles