cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

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.

0 Likes
1 Solution
Anonymous
Not applicable

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)

compare.jpg

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.

View solution in original post

11 Replies
BragadeeshV
Moderator
Moderator

Hi Faruk,

Can you please tell me which is the master and slave here?

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes
Anonymous
Not applicable

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?

psoc_creator_2018-07-23_12-21-10.png

Thanks.

0 Likes
BragadeeshV
Moderator
Moderator

Yes,you need to connect the 2 grounds together.

Did you try communicating the PSoC device with the bridge control panel?

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes
Anonymous
Not applicable

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.

0 Likes
BragadeeshV
Moderator
Moderator

Can you please share the scope shot of the communication bus?

Also share your PWM configuration settings.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes
Anonymous
Not applicable

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

psoc_creator_2018-07-23_13-44-44.png

Here is my Bridge Control Panel output:

USBtoI2C_2018-07-23_13-54-14.png

0 Likes
Anonymous
Not applicable

Is there any interrupt for EZI2C module? For example when data is received, we can trigger the LED.

0 Likes
Anonymous
Not applicable

OK! I managed to provide the communication between Arduino and PSoC. I'll write details here in the evening.

0 Likes
BragadeeshV
Moderator
Moderator

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

Regards,
Bragadeesh
0 Likes
Anonymous
Not applicable

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)

compare.jpg

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.

View solution in original post

BragadeeshV
Moderator
Moderator

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 

Regards,
Bragadeesh