CY8CKIT-059 I2C pins P12_0 and P12_1

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LaPe_296836
Level 2
Level 2
First like received

Hi,

I'd like to build a PCB to hold an -059 board, and some I2C sensors.  Will I have a problem if I connect my I2C bus to the lines at P12_0 and P12_1?  Or is the master function on the bridge chip normally disabled, allowing me to take full control of the bus with the PSoC 5LP?  Is there any advantage/disadvantage to using those pins for my own design (e.g. allowing me to debug my slave devices using the bridge)?

Thanks!

Larry

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

After posting the previous response I became anxious as I could not remember if I have ever used 12[0]/12[1] with CY8CKIT-059.

At the first glance, the silk print on the P12[0] and P12[1] are written 12.0 SCL and 12.1 SDA, so it was promising.

I dug out my old I2C sample project and opened, there I was using P3[0] and P3[1].

So I modified those pins to P12[0] and P12[1] and tested with LM75B (temperature sensor) as below.

And fortunately it seems to be working (^ ^)

IMG_4130.JPG

Tera Term Log

Note: After starting the program, I touched the sensor for a while after it reached to 32 I released my finger.

000-TeraTerm-log.JPG

schematic

Note: The sample was used to test I2C reset so the I2C component has explicit pins but usually it's not necessary.

001-schematic.JPG

pins

002-pins.JPG

main.c

=================

#include "project.h"

#include "stdio.h"

#define LM75B_I2C_SLAVE_ADDR (0x48)

char str[128] ; /* print buffer */

void print(char *str)

{

    UART_PutString(str) ;

}

void cls(void)

{

    print("\033c") ; /* reset */

    CyDelay(20) ;

    print("\033[2J") ; /* clear screen */

    CyDelay(20) ;

}

void splash(void)

{

    cls() ;

    sprintf(str, "PSoC 5LPI2C I2C (LM75B) Test (%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

}

void init_hardware(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */   

    UART_Start() ;   

    splash() ;

    I2C_Start() ; 

}

uint8_t myI2C_ReadByte(uint8_t reg_addr)

{

    uint8_t status ;

    uint8_t value = 0 ;

   

    I2C_MasterClearStatus();

    status = I2C_MasterSendStart(LM75B_I2C_SLAVE_ADDR, I2C_WRITE_XFER_MODE) ;

   

    if (I2C_MSTR_NO_ERROR == status) {

        I2C_MasterWriteByte(reg_addr);

        status = I2C_MasterSendRestart(LM75B_I2C_SLAVE_ADDR, I2C_READ_XFER_MODE); 

    }

   

    if (I2C_MSTR_NO_ERROR == status) {  

        value = I2C_MasterReadByte(I2C_ACK_DATA); // read manufacturers ID from device

    }

    I2C_MasterSendStop(); 

   

    return(value) ;

}

int main(void)

{

    uint8_t data ;

    uint8_t addr = 0 ;

    int i ;

   

    init_hardware() ;

    splash() ;

    

    for(;;)

    {      

        for (i = 0 ; i < 5 ; i++ ) {

            data = myI2C_ReadByte(addr) ;       

            sprintf(str, "%d\n", data) ;

            print(str) ;

            CyDelay(1000) ;

        }

    }

}

=================

moto

View solution in original post

0 Likes
3 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

As I2C bus is open-drain multi-drop type bus,

I think that your program can take full control over the bus as far as the bridge control is not used.

IMHO

Disadvantage:

Added load on the bus as KitProg's I2C bus is also connected.

Advantage:

I think you can use the bridge control to test I2C devices on the bus even before your program starts controlling the bus.

(Note: I've never tested this functionality before, though)

moto

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

After posting the previous response I became anxious as I could not remember if I have ever used 12[0]/12[1] with CY8CKIT-059.

At the first glance, the silk print on the P12[0] and P12[1] are written 12.0 SCL and 12.1 SDA, so it was promising.

I dug out my old I2C sample project and opened, there I was using P3[0] and P3[1].

So I modified those pins to P12[0] and P12[1] and tested with LM75B (temperature sensor) as below.

And fortunately it seems to be working (^ ^)

IMG_4130.JPG

Tera Term Log

Note: After starting the program, I touched the sensor for a while after it reached to 32 I released my finger.

000-TeraTerm-log.JPG

schematic

Note: The sample was used to test I2C reset so the I2C component has explicit pins but usually it's not necessary.

001-schematic.JPG

pins

002-pins.JPG

main.c

=================

#include "project.h"

#include "stdio.h"

#define LM75B_I2C_SLAVE_ADDR (0x48)

char str[128] ; /* print buffer */

void print(char *str)

{

    UART_PutString(str) ;

}

void cls(void)

{

    print("\033c") ; /* reset */

    CyDelay(20) ;

    print("\033[2J") ; /* clear screen */

    CyDelay(20) ;

}

void splash(void)

{

    cls() ;

    sprintf(str, "PSoC 5LPI2C I2C (LM75B) Test (%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

}

void init_hardware(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */   

    UART_Start() ;   

    splash() ;

    I2C_Start() ; 

}

uint8_t myI2C_ReadByte(uint8_t reg_addr)

{

    uint8_t status ;

    uint8_t value = 0 ;

   

    I2C_MasterClearStatus();

    status = I2C_MasterSendStart(LM75B_I2C_SLAVE_ADDR, I2C_WRITE_XFER_MODE) ;

   

    if (I2C_MSTR_NO_ERROR == status) {

        I2C_MasterWriteByte(reg_addr);

        status = I2C_MasterSendRestart(LM75B_I2C_SLAVE_ADDR, I2C_READ_XFER_MODE); 

    }

   

    if (I2C_MSTR_NO_ERROR == status) {  

        value = I2C_MasterReadByte(I2C_ACK_DATA); // read manufacturers ID from device

    }

    I2C_MasterSendStop(); 

   

    return(value) ;

}

int main(void)

{

    uint8_t data ;

    uint8_t addr = 0 ;

    int i ;

   

    init_hardware() ;

    splash() ;

    

    for(;;)

    {      

        for (i = 0 ; i < 5 ; i++ ) {

            data = myI2C_ReadByte(addr) ;       

            sprintf(str, "%d\n", data) ;

            print(str) ;

            CyDelay(1000) ;

        }

    }

}

=================

moto

0 Likes

Dear Motoo, thank you so much for your quick response!

Larry