SC407 with Arduino - device address 0x3F?

251 views
Skip to first unread message

MogensB

unread,
Mar 30, 2021, 4:36:01 PM3/30/21
to retro-comp
Hi,
I have built the SC407 I2C I/O board, and I wanted to test it using an Arduino Pro Mini, before connecting to my SC144 board.

I had trouble getting it to work, until I tried an I2C bus scanner for Arduino, which reported a device address of 0x3F. for the SC407.
 I can now read buttons, and write LEDs on that same device address using Arduino "Wire" library and I2C device address 0x3F.

But reading the docs for SC407 I would expect writes to 0x7E and reads from address 0x7F? I have set jumpers A0, A1 and A2 to the "1" position. Maybe I am misinterpreting the addresses 0x7E and 0x7F? Do they have anything to do with the I2C device address?

Does anyone here know if Arduino behaves differently when it comes to I2C bus master functions or device addressing?

Yeah I know, the Arduino is definitely NOT retro computing... but it comes in handy as a simple test platform sometimes :)

Best regards from,
Mogens

Kurt Pieper

unread,
Mar 30, 2021, 5:16:38 PM3/30/21
to retro-comp
You should scan the SC407 with this program.
The correct I2c address is displayed.
txt remove!

Attention! I installed the PCF8574AP chip and got 7 bit = 027 and 8 bit = 4E.

A note:
03FH = bin 111111
07EH = am 1111110

greeting
Kurt
i2c_scan.ino.txt

Kurt Pieper

unread,
Mar 30, 2021, 5:53:35 PM3/30/21
to retro-comp
Here is my test with Arduino-Uno
Bildschirmfoto_2021-03-30_23-48-24.png

MogensB

unread,
Mar 31, 2021, 4:33:21 AM3/31/21
to retro-comp
Thanks for the I2C scan program sketch for the Arduino. I ran it on my Arduino Pro mini with the SC407 connected, and the output confirms my earlier observation of the I2C address 0x3F.
The SC407 works fine when I read from and write to device address 0x3F in my Arduino sketch.

10:21:32.131 -> Scanning...
10:21:32.177 -> I2C device found at address 0x3F
10:21:32.223 -> done

20210331_102706.jpg

Marco Maccaferri

unread,
Mar 31, 2021, 6:13:27 AM3/31/21
to retro...@googlegroups.com
Il 30/03/21 22:36, MogensB ha scritto:

> I had trouble getting it to work, until I tried an I2C bus scanner
> for Arduino, which reported a device address of 0x3F. for the SC407.
> I can now read buttons, and write LEDs on that same device address
> using Arduino "Wire" library and I2C device address 0x3F.
>
> But reading the docs for SC407 I would expect writes to 0x7E and
> reads from address 0x7F? I have set jumpers A0, A1 and A2 to the "1"
> position. Maybe I am misinterpreting the addresses 0x7E and 0x7F? Do
> they have anything to do with the I2C device address?

The answer is that both are correct, depending on how you "see" the I2C
addressing.

The Arduino hardware, and somewhat "official" I2C documentation, uses
the 7 bit address (3F in your case), however when the hardware sends it
to the device it automatically "shifts" the address 1 bit to the left
because bit 0 is the read/write flag. So again, writing to 7E and
reading from 7F is correct because 3F << 1 = 7E, bit 0 is 0 for write
and 1 for read, thus 7E/7F.

In a (hopefully clear) schematic representation:

+-----+-----+-----+-----+-----+-----+-----+-----+
Bit N. | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+-----+-----+-----+-----+-----+-----+-----+-----+
| I2C address (7 bit) | r/w |
+-----+-----+-----+-----+-----+-----+-----+-----+
3F -> | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1/0 | 7F/7E
+-----+-----+-----+-----+-----+-----+-----+-----+

In the thread 'Need I2C and SPI sample code' I have posted some source
examples for I2C, including a scanner that will show you the address as
the Arduino scanner.

Hope to not have misplaced something.

Best regards,
Marco

MogensB

unread,
Mar 31, 2021, 8:23:53 AM3/31/21
to retro-comp
Thx Marco!
That was a clear explanation about what is going on :) I wasn't aware of the fact that bit 0 in the I2C device address is considered a read/write flag.
I definitely have to read up on the details of I2C addressing and general specifications!

Best regards,
Mogens

andre...@gmail.com

unread,
Mar 31, 2021, 1:51:25 PM3/31/21
to MogensB, retro-comp

i2c overview may be helpful

 

https://www.youtube.com/watch?v=wHYY7GgDa6k

--
You received this message because you are subscribed to the Google Groups "retro-comp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to retro-comp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/retro-comp/f7634f8f-094f-4717-9931-6e2e87785c06n%40googlegroups.com.

MogensB

unread,
Mar 31, 2021, 4:27:01 PM3/31/21
to retro-comp
Thank you for great input! I also stumbled on this site which has lots of info https://www.i2c-bus.org/ 

I am getting things to work here :) ... tonight, I connected the SC407 to the SC144, and I developed a simple Turbo Pascal program for CP/M which reads and writes the SC407 board correctly - and now I clearly see the device address structure, and the I2C frame format. Coding an actual implementation of the protocol is great learning.
I was a bit concerned that my rough example in Turbo Pascal would suffer from timing problems, but everything works fine with the SC407 at least.
Its definitely not the most effective implementation, but for me it is useful for learning about the details.

Happy Easter,
Mogens

Kurt Pieper

unread,
Apr 1, 2021, 6:36:03 AM4/1/21
to retro-comp
Hi, Turbo Pascal is a very powerful software package for CP / M.

1984-85 I worked with turbo.
But not much hanging in the pear (head) anymore.

I2C with display, BME280, TC74A0 or DS3231 are waiting for the connection.

I wish you success. I will accompany your work.

greeting
Kurt
Reply all
Reply to author
Forward
0 new messages