Reply
Posts: 3
Registered: ‎08-31-2017

CP 2120 Sending I2C commands

Hi,

 

I am currently exploring the feasibility of using the CP2120 for I2C communication with an external EEPROM. I have tried to type some commands for writing bytes on the I2C busses, but I can't see anything on the scope. I'm also using the GPIO for controlling two external multiplexers, and his works fine. I'm either typing wrong I2C commands, or there must be something wrong in my firmware.

 

Questions:

#1. I have very little experience with programming communication protocols. I'm therefore wondering whether I need to set up some internal registers on the CP2120 in order to get the I2C to work. I suppose I have to set the clock speed for the I2C clock, but do I need to set the I2C Time Out register, I2C Address or other registers?

 

#2. To type a single I2C command, the datasheet says:

SPI Master: [Command, Num Bytes, Slave Address +W, Data Byte1, ..., Data Byte N] 

Is this all I need to send a simple I2C command?

 

The datasheet for the EEPROM states that "A write operation requires two 8-bit data word addresses following the device address word and acknowledgement." The device address consists of a mandatory one, zero sequence for the first four MSBs (10101 xxxx). The LSB is a R/W (R=1, W=0) bit and the remaining three bits are for device addressing. I therefore tried to type the following i2c command:

spi_write(0x00,0x03,0xA2,[0x55,0x10])

 

Command: 0x00

Num Bytes: 0x03

Slave Address: 0xA2

Data byte 1: 0x55

Data byte 2: 0x10

 

Does anyone know what I'm doing wrong?

Posts: 562
Registered: ‎09-18-2015

Re: CP 2120 Sending I2C commands

Hi @VegardMidt,

 

Is there a particular reason why you are not just using a SPI EEPROM?

 

I'm therefore wondering whether I need to set up some internal registers on the CP2120 in order to get the I2C to work. I suppose I have to set the clock speed for the I2C clock, but do I need to set the I2C Time Out register, I2C Address or other registers?

 

Yes, you need to at least set the clock. The address register is only if you want the device to respond to another I2C master in your system. You probably should set the I2CTO register.

 

Did you read the descriptions of these registers in the datasheet? They are quite clear on what the registers do and whether or not they need to be set or what happens if they are not set.

 

This has me concerned that you may not have paid attention to section 6.1 regarding pull-up resistors.

 

Also, please be sure you are familiar with the CP2120 errata:

 

https://www.silabs.com/documents/public/errata/CP2120Errata.pdf

 

John

Posts: 3
Registered: ‎08-31-2017

Re: CP 2120 Sending I2C commands

Hi @JohnB

Thank you for your reply!

 

Is there a particular reason why you are not just using a SPI EEPROM?

 

Yes, there is. The EEPROM is supposed to be used together with a PCB that are used for product qualification for the IC that we make. We are using the Atmel SAMS70, which features multiple SPI/I2C interfaces, but we have made our own PCB for the micro controller and this only features one additional USART port that can be used as SPI. From this USART port, we want to control two multiplexers (parallel communication), and one EEPROM (I2C because we only have one chip select) for storing sample number.

 

After I wrote the thread, I managed to send the address on the I2C CLK line, but I return NACK every time. I'm using the CP2120 EK board for to see if I can use this chip for mt application. The EEPROM is a development kit from MikroElektrika with a AT24CM02 on. By default, the address pins of the chip should be A0 = 0, A1 = 0 and A2 = 1. Do you have any idea why I always receive a NACK. I belive it has something to do with the CP2120. 

 

Posts: 562
Registered: ‎09-18-2015

Re: CP 2120 Sending I2C commands

Hi @VegardMidt,

 

You'll have to look at the I2C interface with a scope to see what is going on. I can't think of what specifically the CP2120 would be doing that would be causing the I2C EEPROM to NAK the transmissions.

 

John

Highlighted
Posts: 3
Registered: ‎08-31-2017

Re: CP 2120 Sending I2C commands

Hi @JohnB

 

I figured out the problem. I'm using a the EEPROM Click 3 board from MikroElektronika, and i spotted a hardware issue. The silk screen for the SDA line points to a NC pin, and vice versa. When I connected the SDA line to the correct pin, it worked fine! I can see that in the newest version of the board, this issue is fixed.

 

Thank you anyway for you response, I really appreciate that!

 

Vegard