- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I started exploring the world of PSoC with PSOC 4 BLE kit and it was great until I ran into trouble making i2c bus work.
I am trying to hook up i2c character LCD, however it seems like I am unable to initialize i2c properly.
I tried different pins/speeds, using low level i2c api and high level - nothing helps.
I check the SCL pin with oscilloscope and don't see any signal.
I tried example projects - still no signal on SCL and SDA..
I attach my code and project:
<pre><code>
#include <project.h>
#include "LiquidCrystal_I2C.h"
__IO uint32_t TimingDelay = 0;
uint32_t DeviceAddr = 78;
uint16 shit=0;
int i=0;
int main(void)
{
CyGlobalIntEnable;
PWM_1_Start();
I2C_M_Start();
PWM_1_WriteCompare(0);
while(1){
I2C_M_I2CMasterWriteBuf(DeviceAddr, (uint8 *)DeviceAddr, 1, 0);
I2C_M_write_byte(DeviceAddr,67);
I2C_M_I2CMasterSendStart(DeviceAddr,0);
CyDelay(1000);
}
}
</code>
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You find documentation and schematics for all the kits you successfully installed under Programs(x86)\Cypress\,,,\Hardware
The port5 pins fur I2C are on header J10 pins 12 and 14
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum, Sarunas.
I would suggest you to use P5_0 and P5_1 for I2C, the required pullup resistors are already provided on the board and the FRam is on the same bus
Your first access to the I2C interface must fail:
I2C_M_I2CMasterWriteBuf(DeviceAddr, (uint8 *)DeviceAddr, 1, 0);
When the device address of the I2C-LCD really is 0x78 you are trying to submit a databyte from the address of 0x78 which is from flash, Probably not what you want.
You did not provide a link to the LCD's datasheet, so I cannot check what you have to send.
The following WriteByte() function will fail because you did not issue a Start() condition.
The next SendStart() is not followed by a SendStop()
All I2C-APIs return a status indicating success or failure. Best is to check that.
For both the APIs SendStart() and WriteBuf() the last parameter has a meaningful #define (to be found in the .h-file), better to use that, makes it clear what you want to do.
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
Sarunas: Well I have look over your program and I think there is a few issue with it. The I2C pins are P3-4 and P3-5 these are set for the Arduino I2C output pins on the Pioneer board J3. Also you need to have pullup resistors on these pins. Also I have no ideal what I2C LCD display you are using. So I can't check your address and commands. Also if you look at the PSOC Ble example program they have both an I2C device and also an I2C LCD device in their program. There is also a I2C test program in the examples that should help also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You will not see a signal without pullups.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! I will try your suggestions 🙂 i think i tried all allowed ports already, but will do it again.
UPDATE: I managed to see the signal. The problem was indeed passing an argument to I2C_MASTERWRITEBUFFER. I tried sending the pointer of the variable, while it wants an array 🙂
P.S. Are there pins on the pioneer baseboard to which pins 5.0 and 5.1 are connected? Can't find anything in documentation.. also doesn't seem to be on the board.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You find documentation and schematics for all the kits you successfully installed under Programs(x86)\Cypress\,,,\Hardware
The port5 pins fur I2C are on header J10 pins 12 and 14
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got it working on other pins. Thanks for your help. It turns out, that address had to be shifted by one bit (compared to stm32 i2c configuration).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fine!
Happy coding
Bob