I2C Problem with 8C24123

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Hi,

   

I am attempting to get two 8C24123 PSOC 1's to communicate over I2C.

   

On the master, using I2Cm (called MOTOR) , I init as follows

   

  M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO);

   

  M8C_EnableGInt;

   

  MOTOR_Start();

   

I then send data as follows

   

BYTE CS = speed + MOTOR_ADDRESS;

   

BYTE data[3];

   

   

data[0] = speed;

   

data[1] = 0;

   

data[2] = CS;

   

   

MOTOR_bWriteBytes(MOTOR_ADDRESS, data, 3, MOTOR_CompleteXfer);

   

 

   

On the slave PSoC, I use the EZI2Cs (called I2C) and init as follows

   

struct I2C_regs

   

{

   

BYTE data[3];

   

BYTE shadow;

   

} MyI2C_Regs;

   

 

   

MyI2C_Regs.data[0] = 0;

   

MyI2C_Regs.shadow = 0;

   

   

I2C_SetRamBuffer(4,3,(BYTE *)&MyI2C_Regs);

   

   

    M8C_EnableGInt;

   

I2C_Start();

   

 

   

Then I just check for data values in loop 

   

 

   

while(1) {

   

    // do some checks on MyI2C_regs.data[0]

   

}

   

 

   

The MOTOR_ADDRESS is 0x60

   

The attached lower image shows the PSoC to PSoC communication. The slave PSOC acks the Write request to address 0x60, but it Naks the first byte written (0x46) and the communication ends. I also never detect data[0] as being 0x46 on the slave (as if the data has not been passed from the EzI2C routines to the ram location).

   

On the upper image, I am using the Microchip PicKIT serial analyser as the slave, with the PIC kit set to slave mode and address 0x60. In this case, the PicKIT NAK's (or ignores) the write to slave 0x60 from the master.

   

I usually do the same sort of communications from a 8C29466 as the master with 8C24123 as slave and the 123 slave code has worked fine in the past.

   

All the SCL/SDA pins are Open Drain Low mode. Pull ups are 4K7

   

Does anyone know why this may not be working correctly?

   

Thanks,

   

   John

0 Likes
15 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Consider posting a project for forum to look at entire

   

setup and routing -

   

 

   

    

   

          

   

“File”                                                           Designer

   

“Archive Project”

   

Use Firefox or IE, not chrome to post.

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

I2C  Master Project

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 I2C Slave Project

0 Likes
Anonymous
Not applicable

I2C Master (posted via FF)

0 Likes
Anonymous
Not applicable

I2C Slave (FF)

0 Likes
Anonymous
Not applicable

I have posted the files both with Chrome and with Firefox, but using firefox did not send the files.

   

I have downloaded the files that I uploaded with Chrome and they seem fine. If not, let me know and I will upload them again.

0 Likes
Anonymous
Not applicable

I have recreated the master and slave programs by using a minimal implementation.

   

This gives exactly the same results, the write to slave at 0x60 is acked, but the write of the first data byte 0x46 is

   

NAK'd and the master sends a stop.

   

I have no idea why this will not work.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Trying to upload the attachment again.

0 Likes
Anonymous
Not applicable

 I made some further progress.

   

I noted that with the PICKit Serial analyser, when it sends a master write request for address 0x60, then according to

   

the rising edge of the I2C CLK, it is actually sending a 0x30 (it is one bit out).

   

So I changed my master to send to address 0x30 and set the PICKit serial analyser to I2C slave at address 0x60.

   

Sure enough the PICKit started receiving data from the master and it gave the correct 3 data bytes.

   

Which is totally weird, because the data bytes were not right shifted 1 bit like I had done to the address byte to make this work.

   

However, sending to the 8C24123 slave (slave still set to 0x60) had the slave ignoring the master write request.

   

I then changed the 8C24123 slave to address 0x30, but then I had the same as before. The slave Ack's the master request, but Nak's the first data byte sent from the Master (just the same as before).

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Probably you get confused about the addressing scheme in I2C. In the PSoC implementation the addressing is done by the software, so the address you specify (in the range of 8 to 120) is automatically shifted left by one (1) and the R/W bit is appended. This is NOT done for data-bytes of course!

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Thanks Bob, but I am still confused.

   

On the PSOC, if I put 0x60 as the address for the write, there is no apparent shift. The seven bits are sent as I would expect 110 0000.

   

When I use the Microchip PicKIT serial analyser and ask it to write to address 0x60, this is where I see the left shift, as the PicKIT sends 011 0000. So I have to change the PSoC to write to 0x30 to make it talk to the Microchip device (in other words, I need to left shift the address, it is not done by the PSoC).

   

Addressing aside, it still does not explain why my PSoC slave will not accept more than 1 data byte.

   

Has anyone tried I2C between two 8C24123 devices? If you look at my master/slave projects, they are so minimal, it would appear that the Ez slave module is the issue.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Actually I have done a couple of different I2C communications with different PSoCs as master and as slave. Additionally I have got a I2C analyzer which exactly shows all the bus actions. so believe me. Have a look here: www.robot-electronics.co.uk/acatalog/I2C_Tutorial.html

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Thanks for the article link. Their explanation of the I2C addressing makes sense.

   

I have been using I2C with the PSoC without issue on a few projects over the years. I even have a project which uses the 8c24123  as the slave, it works fine, but I only ever send it one data byte but it also uses an earlier version of Ez12Cs, so that may be the difference?

   

Given your explanation of the addressing, I can get the 8C24123 master to talk to the MicroChip PicKIT Serial analyser just fine, so I know now that the master side of things is working fine.

   

But as for the slave side on the SC24123, it still NAK's the first data byte after the address byte.

   

I have no idea where to go from here as I have nothing to debug the slave side code further.

0 Likes
Anonymous
Not applicable

 Today, I tried making a I2C slave using the I2CHW module.

   

With this module, the I2C communication is working.

   

This means I have all my programming correct and my wiring correct.

   

I can only conclude that the EzI2Cs module does not work correctly for some reason.

   

I will have to leave it there and move on now that I have a working connection.

   

Hopefully this thread will be helpful for someone else in the future.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Great that you got it to work!

   

 

   

Nonetheless I would ask you to inform Cypress abvout that issue. On top of this page under Support&Community -> Technical Support -> Create a MyCase. You may refer to this thread where your attached files are still accessable.

   

 

   

Nob

0 Likes