- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am currently using a PSOC5LP and trying to interface an ADXL345 Accelerometer using I2C. My goal at the moment is to simply read one byte from the accelerometer which corresponds to the device's ID. I have the PSOC as the master and the Accelerometer as the slave. Through stepping through the code in the debugger as well as printing to the LCD display, I have found that I am able to successfully send a I2C_MasterSendStart(). I verified that this was the case because the function always returns I2C_MSTR_NO_ERROR. The problem arises when I try to write the specific slave (Accelerometer) address over to the slave so that I can read from it. The function call "status = I2C_MasterWriteByte(address)" always returns I2C_MSTR_NOT_READY.
One of the things I have been thinking about is the setup and hold times for writing to and reading from the slave. However, I don't think that should be a big issue considering the speed of the link should a good speed to handle those issues.
Mitchell
Solved! Go to Solution.
- Labels:
-
PSoC 5 Device Programming
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tested your program with HIH6130 (address = 0x27) and MSS (Marubun Sensor Shield),
which has 10K pull-up for both SDA and SCL.
And inside the debugger at least I could iterate the for(;;) loop a few times with step through.
So I suppose if you connect an external I2C device with 10K pull-ups the program may work OK.
My PSoC Creator Debug screen, the cursor is at devID = I2C_MaterReadByte(I2C_NAK_DATA),
which means the program has passed previous lines without error.
Note: As I'm using debugger, this might not be the problem but if you run the loop without any delay
may be some I2C device can not deal with the repeat.
Attached is your project with my modification for HIH6130 and using UART instead of LCD.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tested your program with HIH6130 (address = 0x27) and MSS (Marubun Sensor Shield),
which has 10K pull-up for both SDA and SCL.
And inside the debugger at least I could iterate the for(;;) loop a few times with step through.
So I suppose if you connect an external I2C device with 10K pull-ups the program may work OK.
My PSoC Creator Debug screen, the cursor is at devID = I2C_MaterReadByte(I2C_NAK_DATA),
which means the program has passed previous lines without error.
Note: As I'm using debugger, this might not be the problem but if you run the loop without any delay
may be some I2C device can not deal with the repeat.
Attached is your project with my modification for HIH6130 and using UART instead of LCD.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
At first sight: The returned i2c status is a bit field, so
if (status == I2C_MSTR_BUS_BUSY) should be replaced with
if (status & I2C_MSTR_BUS_BUSY). Same for all the other occurrences.
Datasheet for the device says (Pg. 18)
the 7-bit I2C address for the device is 0x1D when the ALT ADDRESS pin is high
Since the component uses 7 bit addresses you should (test) change your slave address to 0x1D
What is the value of the pull up resistors for sda and scl? Are you using a CY9CKIT-059??
There is some internal logic connected to P12_0 and _1 to care for different supply voltages, This may conflict with the VREF controlled pins that you use.
Bob