CY8CKIT-059 supporting multiple I2C traffic

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

cross mob
RiKn_1565556
Level 2
Level 2

Hi All,

I'm working with a CY8CKIT-059 and I'm hung up on a I2C question that I'm hoping someone smarter than me can answer.

My basic design is pretty simple, using an I2C element I'm sending formatted text to an OLED display (1" EBAY device) with the usual informational messages an application would be sending to such a display.

Having accomplshed that, I'm now ready to move on to doing some data taking, but to do that I'll need to get some precise timestamps by communicating with a second I2C device, a DS3231AS based mini-board (also of Ebay origins).

My question is this - can I talk to this board using the same I2C bus as the OLED Device or do I need to set up another I2C element with a separate SDA/SCL pair?

I might add here that I eventually wish also to add a third SD card I2C-based device to do data logging to, but one step at a time.

I'm using PSOC Creator 4.2.

Rich

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

You seem to test the address only by sending Start,

but from my experience there are I2C devices which requires 2 bytes transaction,

and in case transaction is less than 2 bytes, the device grabs and holds the bus.

That was quite annoying, but by reading 2 bytes,

we could work around the problem.

And meantime most of other "well behaving" I2C modules

did not show problem with this method.

So I modified your TestI2CAdress as below,

(Please allow me to use I2C instead of I2C_1)

==========================

#define TIMEOUT_MSEC 300u

#define I2C_I2C_ACK_DATA (0u)

#define I2C_I2C_NAK_DATA (1u)

Bool TestI2CAddress(uint8 Address)

{

    uint32 Status ;

    uint8 data[2] ; /* dummy buffer to read */

 

    I2C_I2CMasterSendStart(Address, (uint32_t)0u, TIMEOUT_MSEC) ; /* for write */

    Status = I2C_I2CMasterWriteByte(Address, TIMEOUT_MSEC) ;

    Status = I2C_I2CMasterSendRestart(Address, (uint32_t)1u, TIMEOUT_MSEC) ; /* for read */

    CyDelay(1) ;

    I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA, &data[0], TIMEOUT_MSEC) ;

    I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA, &data[1], TIMEOUT_MSEC) ;

    Status = I2C_I2CMasterSendStop(TIMEOUT_MSEC) ;

 

    if (Status) {

        return FALSE ;

    } else {

        return TRUE ;

    }

}

==========================

And I loaded 4 sensors on MSS (Marubun Sensor Shield) and put it on CY8CKIT-044.

CY8CKIT-044_SS.JPG

By running the program I was surprised that there were 3 more I2C sensors on the board.

I2C_bus_scan.JPG

Anyway, it seems working, somewhat slow though...

Attached is my test program for CY8CKIT-044,

hopefully main.c should be usable for your board, too.

moto

View solution in original post

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

You can connect more than just two (2) devices to a single I2C bus. Each device must have a different address. and must act as slave.

Bob

0 Likes

Hi Bob,

Thanks for your reply, sorry I've been dawdling in my response.

I've been trying to connect to the second I2C device and decided to try a scan of the I2C bus to find out what address it really was showing up as.  I found your I2C Scan routine from Last year and have adapted (fixed the device settings) to work with my CY8CKIT-059.

Besides stipulating the processor type, adjusting some of the I2C and UART calls, and setting the 3.3VDC settings, it runs - sort of.  It starts up normally and seems to be running like crazy, but not producing any output.  After about 5 minutes of doing this, it spit out "Device at 0x00 found" and then just continued running.  I've inspected the code and it makes sense to my newby mind, but I'm sure there are differences between PSOC4 and PSOC5 that I don't yet understand.

Has anyone successfully used this program with a CY8CKIT-059?  Do you have a more recent version of this seemingly useful program?

Thanks again

Rich Knowles

0 Likes

Also -, I have an OLED display on that bus which works, and a RTC module on the same bus that I'm trying to understand the I2C address is.

0 Likes

Rich, can you please post your complete project so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file.

Bob

0 Likes

Bob,

I can't seem to be able to attach the bundle to the post.  I've tried both options offered but they tell me it is forbidden to attach the zipfile.  Am I missing something?

0 Likes

Use the option "Advanced Editor" (right hand upper corner of reply window) and then cclick on "attach file"

Bob

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

Bob,

Ahhh, much better.  Here is the file.

Rich

0 Likes

Did you connect pull up resistors (10k) to sda and scl ?

Bob

0 Likes

Yes, I have 10K resistors on each leg.

Right now I have a working OLED display on that I2C bus, and am seeking to figure out the actual address reflected to the bus for a RTC applique module (a'la ebay/China)

Rich

0 Likes

Hi Rich,

You can also use Bridge control panel to list out the I2C slave devices on the bus. (you will know the slave address this way)

You can refer to "Connecting Bridge Devices" section from Bridge Control Panel -> Help-> Help Contents-> Introduction.

Refer to the following link for installation: http://www.cypress.com/documentation/software-and-drivers/psoc-programmer-secondary-software

Thanks,
Shanmathi

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

You seem to test the address only by sending Start,

but from my experience there are I2C devices which requires 2 bytes transaction,

and in case transaction is less than 2 bytes, the device grabs and holds the bus.

That was quite annoying, but by reading 2 bytes,

we could work around the problem.

And meantime most of other "well behaving" I2C modules

did not show problem with this method.

So I modified your TestI2CAdress as below,

(Please allow me to use I2C instead of I2C_1)

==========================

#define TIMEOUT_MSEC 300u

#define I2C_I2C_ACK_DATA (0u)

#define I2C_I2C_NAK_DATA (1u)

Bool TestI2CAddress(uint8 Address)

{

    uint32 Status ;

    uint8 data[2] ; /* dummy buffer to read */

 

    I2C_I2CMasterSendStart(Address, (uint32_t)0u, TIMEOUT_MSEC) ; /* for write */

    Status = I2C_I2CMasterWriteByte(Address, TIMEOUT_MSEC) ;

    Status = I2C_I2CMasterSendRestart(Address, (uint32_t)1u, TIMEOUT_MSEC) ; /* for read */

    CyDelay(1) ;

    I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA, &data[0], TIMEOUT_MSEC) ;

    I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA, &data[1], TIMEOUT_MSEC) ;

    Status = I2C_I2CMasterSendStop(TIMEOUT_MSEC) ;

 

    if (Status) {

        return FALSE ;

    } else {

        return TRUE ;

    }

}

==========================

And I loaded 4 sensors on MSS (Marubun Sensor Shield) and put it on CY8CKIT-044.

CY8CKIT-044_SS.JPG

By running the program I was surprised that there were 3 more I2C sensors on the board.

I2C_bus_scan.JPG

Anyway, it seems working, somewhat slow though...

Attached is my test program for CY8CKIT-044,

hopefully main.c should be usable for your board, too.

moto

0 Likes

Arigato TanakaSan, gokurosan desu!

Thanks for your time and effort.  I've continued to move ahead independently with the device I started out working with and have spent the past couple weeks exploring how to make the DS3231 RTC work (and it is doing that).   As soon as I button up my code I'll give this routine a go - I plan on doing some more with I2C which is why I was experimenting with an address scanner.  I'll post again after I look at it.

I'm also sure that a working scanner will be a valuable aid to others who are trying to figure out how to slay this dragon.  ( ^ U ^ )

Rich

0 Likes

Also,

Talking to more than one sensor turned out to be easier than I thought.  I think I was just over-thinking it.

Jaa mata

0 Likes