- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
By running the program I was surprised that there were 3 more I2C sensors on the board.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the option "Advanced Editor" (right hand upper corner of reply window) and then cclick on "attach file"
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you connect pull up resistors (10k) to sda and scl ?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
By running the program I was surprised that there were 3 more I2C sensors on the board.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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