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

CAPSENSE™ & MagSense Forum Discussions

Petervg
Level 1
Level 1
5 sign-ins First solution authored First reply posted

I'm using the CY8C4014 in an application where the PSoC is only performing capsense and need to be read out over I2c using an external MCU. We've setup the PSoC with EZI2C and CapSense, performed the tuning using the tuner application and exported a PDF of the registermap so an external MCU could read this over I2C. The address of the EZI2C is set to 0x08 and bus speed to 400Khz (even though I'm only using 100Khz in the final application).

When the external MCU reads the whole registermap at once, everything is working properly. As soon as the application starts up, I first transmit a write command to address 0x08 followup with a 0 to set the read pointer to address 0x00. Next I issue a read command to address 0x08 to read out all information from the registermap. All works as expected:

ReadAllRegisters.JPG

Note 1: in above screenshot the first byte (value at register map address 0x00) is 0x16. Not shown in the screenshot because the frame is too long is the values at address 0x18. This value is 0x00 when no buttons are pressed.

Note 2: the button presses are detected. I can use the value in register map address 0x18 to see which buttons are pressed. This works like it should.

 

PROBLEM DESCRIPTION:

I only need SNS_STATUS0 as I only have 6 buttons I need to read. Reading the whole registermap makes no sense as I don't need all that information in the actual application. So I modifed the code to issue a write command to address 0x08 with the payload '0x18' to set the base address to 0x18 (the address in the register map where the value of SNS_STATUS0 resides) and next read commands should start at this base address.

Adress 18.JPG

In my application however, after setting the base address to 0x18, the content of address 0x00 is still transmitted. I've searched through the datasheet of the EZI2C peripheral and compared figure 9 on page 78 with the actual frames being sent using a logic analyzer and I cannot see any difference.

This is what is in the datasheet of the EZI2C peripheral:

Fig9 pg78.JPG

And this is what I send and receive (the last byte in the screenshot is the answer of the PSoC and the value 0x16 is actually byte 1 of the config ID on address 0x00 and not the value of SNS_STATUS0 at address 0x18:

First read single register.JPG

Subsequent reads also yield the same (byte 1 of the config ID on address 0x00 and not SNS_STATUS0 on address 0x18). To be clear: the frame in the screenshot above containing the write command to 0x08 with payload 0x18 is sent before the frame below.

Subsequent read single register.JPG

 

Different approach - same problem:

I also tried to use a restart condition on the I2C bus as indicated in fig 9 on page 78 of the EZI2C datasheet, but I stil get the value of addres 0x00 in the registermap instead of the value on address 0x18

Read single byte restartJPG.JPG

Really scratching my head here... Anybody has experience with this?

Many thanks in advance!
Peter

 

0 Likes
1 Solution
Petervg
Level 1
Level 1
5 sign-ins First solution authored First reply posted

Hi @Hari ,

Thanks for the tip! Indeed this was the problem! I looked into the datasheet again and indeed this is described on page 76/77 ("Interface as seen by an external master"):

Sub 1.JPG

Sub 2.JPG

So I now send a write command to slave address 0x08. After that I send 0x00 0x18 to set the pointer in the register ap to 0x18. The PsoC will now start sending back data starting from the register map address 0x18:

Set address, read 1st byte.JPG

All subsequent reads can be done without resetting the address. In the screenshot below the 0x00 is indeed the content of address 0x18 in the register map.

Subsequent read.JPG

Thanks again for the support!

With kind regards
Peter

View solution in original post

0 Likes
2 Replies
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi @Petervg 

 

The issue here is that you used the 16-bit sub-address style. In that case, you need to provide the 16 bit address in the write command. For example, to read the second byte, you need to write 0x00 0x02 in the write command and then read the data.

In Bride control panel style, the command would be:

w 08 00 2E p

r 08 x x p

to read 2 bytes from address 0x2E. 

 

Please try this out and do let us know if it works 🙂

 

Best regards, 
Hari

0 Likes
Petervg
Level 1
Level 1
5 sign-ins First solution authored First reply posted

Hi @Hari ,

Thanks for the tip! Indeed this was the problem! I looked into the datasheet again and indeed this is described on page 76/77 ("Interface as seen by an external master"):

Sub 1.JPG

Sub 2.JPG

So I now send a write command to slave address 0x08. After that I send 0x00 0x18 to set the pointer in the register ap to 0x18. The PsoC will now start sending back data starting from the register map address 0x18:

Set address, read 1st byte.JPG

All subsequent reads can be done without resetting the address. In the screenshot below the 0x00 is indeed the content of address 0x18 in the register map.

Subsequent read.JPG

Thanks again for the support!

With kind regards
Peter

0 Likes