I2C LPC1788 - Reading a slave registers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C LPC1788 - Reading a slave registers

Jump to solution
2,231 Views
abderrezak
Contributor III

Hi all of you,

I'm using I2C to control a touch panel with LPC1788 used as master. I'm using LPCOpen driver to gain time.

 

TouchPanel Iitialization

     Pin muxing I2C

     Chip_I2C_Init

     Chip_I2C_SetClockRate // 100000

     Board_I2C_SetMod        // Pooling mode

 

The touch panel contain many register (page 6 - http://www.mouser.com/ds/2/291/NHD-4.3-480272EF-ATXL-CTP-28216.pdf -).

First of all I want to read or write one of this register on the slave, but the broblem is when I prob SDL SCA with a serial decode I capture only the Address 0x70 in read or write. It seems that the data and the Register Slave Adress isn't send.

 

I'm using this command to Send Data: Chip_I2C_MasterSend(BOARD_CTP_ID, CTP_ADDR, buf, 3);

The buf contain at 0 the register Adresse then from buf[1] it contain the data I want to write.

 

In case of Read I use Chip_I2C_MasterRead(BOARD_CTP_ID, FT5336_I2C_SLAVE_ADDRESS, &buf[2], 1);

 

What is the correct way to use a Read Slave Register, and Write Value in Slave Register?

 

Thank you

Labels (2)
Tags (3)
1 Solution
1,656 Views
rolfmeeser
NXP Employee
NXP Employee

The scope traces show your request is NAK'ed (no response from the slave device).

It may be a case of a shifted slave address: Try specifying 0x38 instead of 0x70 as the address.

View solution in original post

3 Replies
1,657 Views
rolfmeeser
NXP Employee
NXP Employee

The scope traces show your request is NAK'ed (no response from the slave device).

It may be a case of a shifted slave address: Try specifying 0x38 instead of 0x70 as the address.

1,656 Views
abderrezak
Contributor III

Thank you! Worked

Can you explain to me this thing about slave shifted addresses or give me some doc

0 Kudos
Reply
1,656 Views
rolfmeeser
NXP Employee
NXP Employee

There are two kinds of people: Those like you and me who understand the original Philips I2C specification (http://www.nxp.com/documents/user_manual/UM10204.pdf​), and those who don't...

The I2C spec defines a 7-bit address space 0x00...0x7F in steps of one. In this world the address of your device is 0x38.

However, the address byte sent on the bus has the 7-bit slave address field shifted left by one bit (bits 7:1), with bit 0 indicating read/write operation. Now some prefer to treat the address byte as the slave address, so they get 0x00...0xFE in steps of two, and your slave address becomes 0x70.

You will find both interpretations in data sheets, and some trial and error is often involved to get it right.

(edited to get the example right...)