I’m trying to use I2C with the BL4S200 board, but I’m having some issues. First of all, I have some questions about the connection. When using port D (default), are these the correct connections to use?
- SCL (PD6) corresponds to connector J11 pin 1 (PD6_TXE)?
- SDA (PD7) corresponds to connector J11 pin 6 (PD7_RXE)?
I have connected SCL and SDA with the corresponding 5 kOhm pull-up resistors, each connected to a 5 Volt Vdd.
I started with simple tests, but I immediately encountered a problem because I’m not measuring the expected voltages.
I initialized the I2C with i2c_init() and then used these basic commands:
- With i2c_SCL_H(), I measure a voltage of -5.47 Volts between GND and SCL. Shouldn’t I be measuring 5 Volts?
- With i2c_SCL_L(), I measure a voltage of +5.68 Volts between GND and SCL. Shouldn’t I be measuring 0 Volts?
- With i2c_SDA_H(), I measure a voltage of +2.34 Volts between GND and SDA. Shouldn’t I be measuring 5 Volts?
- With i2c_SDA_L(), I measure a voltage of +2.34 Volts between GND and SDA. Shouldn’t I be measuring 0 Volts?
This is the first time I’m trying to use I2C with Rabbit, and I’m definitely doing something wrong. Can you help me?
You can’t use I2C on that serial port. In reviewing the schematic, I see that serial port E (PD6/PD7) goes an RS232 driver (U20) and will only work with those levels. Additionally, the Tx pin is output only, and the Rx pin is input only, so you cannot use it for two-way I2C. And the BL4S200 has a VCC of 3.3V, so even if you were using 5V pull-ups directly connected to the I/O lines, you’d risk damaging them.
I2C is typically used to connect components directly on a PCB, or perhaps across a PCB interconnect. It wasn’t designed to drive signals across wired connections. You’d typically have I2C devices connected to a Rabbit Core Module (RCM) on your own PCB design.
The BL4S200 has an RS485 driver on serial port C (PC2/PC3) that is better suited for two-way bus communications to external devices. There’s also an RS422 driver (U12/U13) connected to the RabbitNet RJ-45 connectors on J6 and J8. Those lines run a SPI port (chip select, clock, data in, data out) across differential signals to a remote device. It’s not a standard use of RS422, so you would need to design some of your own hardware to convert the differential signals back to TTL levels if you wanted to connect to a remote SPI device.
I don’t know what type of device you’re trying to connect to the BL4S200, but I’d recommend exploring RS485 as a more appropriate communications bus.
I tried that connection because the example (Samples\I2C\i2c_24LC16.c) says “The I2C library defaults to using PD6 as SCL and PD7 as SDA”. And I had looked at the schematic and there I saw that port PD6 and PD7 ended up in U20 (J11 pins 1 and 6). Why then in the example they say to use PD6 and PD7?
I had used that connection because from the manual I saw that PD6/7 is also part of parallel port D. And in the I2C_SW.LIB library, it is used for I2C the port D which is made Open Drain during i2c_init() initialization.
The ultimate goal is to connect a Honeywell flowmeter Zephyr (which we already have) that uses the I2C protocol, so I’m trying to figure out how to connect it.
Thanks for the help, I’m a beginner, I’m still trying to understand.
In this case, that sample isn’t appropriate for the hardware you’re using since those pins are wired into circuitry for an RS232 serial port.
The Samples directory contains generic samples of features that may or may not be available on all Rabbit products. For example, not all products have Ethernet connections.
There are also product-specific samples in subdirectories. In your case, the BLxS2xx directory has samples for the BL4S200. But even in this directory, the Wi-Fi samples are only for a discontinued version of the product that was based on the RCM5400W.
OK, I understand.
So actually there is no easy way to connect the BL4S200 board via I2C protocol?
Before, I don’t know if I understood correctly, you were saying that port C could be used?
In case I want to try that, what should I do? Where and how should the SCL and SDA cable (from flowmeter) be connected?
Thanks so much, I didn’t expect it to be that complicated.
Correct – there isn’t an easy way to connect an I2C sensor to the BL4S200.
The “BL” products are designed as single-board computers (SBCs) with the intention that you’ll connect them to other (external) devices via cables using physical signaling designed for that purpose and typically using something other than TTL (Vcc/GND) level signals.
The “RCM” products are designed as plug-in modules for your own PCB design. I2C sensors are also designed for PCBs (using TTL levels), and not for “external” connections.