- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
I want to provide an i2c interface between Arduino UNO and PSoC 5LP (cy8ckit-059). I completed the i2c lesson on YouTube and I managed to setup the communication between PSoC and Bridge Control Panel.
Then, I want to send a byte from Arduino to PSoC. But I haven't done yet. I wired correctly, set clock values to the same value, developed the code for both sides correctly but when I send PSoC a byte, there is nothing.
Is there someone who could setup i2c interface between these devices before? Or someone who can help me?
Thanks
Related topic: Re: I²C Communication Arduino -> PSoC
Here is my files;
Arduino side
#include <Wire.h>
void setup() {
Serial.begin(9600);
Wire.setClock(100000);
Wire.begin(8);
}
void sendWire(){
Serial.println("Sending...");
Wire.beginTransmission(8);
byte y=Wire.write(0x00);
Wire.endTransmission();
Serial.println("Sent...");
}
void loop() {
while(Serial.available()>0){
int x=Serial.read();
if(x==49){
sendWire();
}
}
}
PSoC main.c
#include "project.h"
int main(void)
{
uint8 i2cbuf[1];
CyGlobalIntEnable; /* Enable global interrupts. */
PWM_1_Start();
I2C_Start();
I2C_SetBuffer1(1,1, i2cbuf);
i2cbuf[0]=1;
for(;;)
{
PWM_1_WriteCompare(i2cbuf[0]*20);
}
}
Message was edited by: A. Faruk UNAL The files were added.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is my solution:
1. Sure that you connected devices' grounds together. GND -> GND
2. Sure that SDA and SCL connections.
3. Make test using KitProg.
3. It's the most important thing that sure that you have the right code in Arduino side. (You can write the code according to KitProg command)
You can see equivalent diagram between KitProg and Arduino. It's not official, just based on my experiences. So, there may be differences for different applications.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Faruk,
Can you please tell me which is the master and slave here?
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bragadeesh,
Thanks for replying. As I said, I want to send a data from Arduino to PSoC. So, we can say Arduino is the master device. Also, when I designed the PSoC, I added EZI2C module.
Yesterday, someone told me I had to connect devices' ground common(wire ground to ground). Is it true?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes,you need to connect the 2 grounds together.
Did you try communicating the PSoC device with the bridge control panel?
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I connected the 2 grounds together now. There is nothing on PSoC LED, but write() function on the Arduino returns 1 that is good. It means I managed to send data
Yes, I tried Bridge Control Panel. I managed to communicate I have a problem only with Arduino communication.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please share the scope shot of the communication bus?
Also share your PWM configuration settings.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't have a physical scope at my home. If there is a scope which based on software, I can use it.
Actually, my PWM configuration must be right because I have an interrupt for a pin now and when I clicked the pin, it changes i2cbuf[1] value and I can see dimmer or brighter.
Also, my project files are here: https://quickfileshare.org/7qt/I2C_Ard_Simple.cydsn.zip
Here is my Bridge Control Panel output:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there any interrupt for EZI2C module? For example when data is received, we can trigger the LED.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK! I managed to provide the communication between Arduino and PSoC. I'll write details here in the evening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad that it worked. Please share your comments on what went wrong before so that other community users would be benefited from this thread.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is my solution:
1. Sure that you connected devices' grounds together. GND -> GND
2. Sure that SDA and SCL connections.
3. Make test using KitProg.
3. It's the most important thing that sure that you have the right code in Arduino side. (You can write the code according to KitProg command)
You can see equivalent diagram between KitProg and Arduino. It's not official, just based on my experiences. So, there may be differences for different applications.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. Check if you're using the right SDA SCL pins for the arduino.
From your previous responses I can see you're using arduino UNO. Check if you're using the right pins. A4 (SDA), A5 (SCL) .
2. What are the pins you're using in your PSoC?
3. Try sending values other than 0 to PSoC
4. Try this code in the arduino
#include <Wire.h>
void setup() {
Wire.setClock(100000);
Wire.begin(8);
}
void loop()
{
Wire.beginTransmission(8);
Wire.write(127);
Wire.endTransmission();
}
regards,
Bragadeesh
Bragadeesh