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
I then send data as follows
BYTE CS = speed + MOTOR_ADDRESS;
data = speed;
data = 0;
data = CS;
MOTOR_bWriteBytes(MOTOR_ADDRESS, data, 3, MOTOR_CompleteXfer);
On the slave PSoC, I use the EZI2Cs (called I2C) and init as follows
MyI2C_Regs.data = 0;
MyI2C_Regs.shadow = 0;
Then I just check for data values in loop
// do some checks on MyI2C_regs.data
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 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?
Consider posting a project for forum to look at entire
setup and routing -
Use Firefox or IE, not chrome to post.
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.
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.
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).
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!
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.
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
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.
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.
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.