cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

shyuc_4247356
Employee

I am trying to send some data from one I2C master to one non-exist I2C slave on the bus.

the I2C bus only has one master and the SDA/SCL lines have been pull-up as suggested by the spec.

could anyone help me to understand if that is even possible?

seems after master received the NACK after tx of Address, it wouldn't take any write to the I2C_DATA_REG and STOP condition will generated after TRANSMIT bit been set (this may because the lines are all been pull-up?).

0 Likes
Reply
1 Solution
JoMe_264151
Expert II

The I2C protocol requires that a NAK is received to stop transmission. So there will be no workaround that confirms I2C.

What is your actual problem causing, can you tell us a bit more (upload project??)?

Bob

View solution in original post

0 Likes
Reply
4 Replies
BragadeeshV
Moderator
Moderator

Hi xiang.yuan_4247356​,

When a I2C master receives a NACK, a STOP condition is generated and the data wouldn't be transmitted.

Regards,

Bragadeesh

Regards,
Bragadeesh
shyuc_4247356
Employee

thx BragadeeshV_41​,  so means this is hard coded in the Hardware, do I get this correct?

if so, is there any workaround available in the FW?

0 Likes
Reply
JoMe_264151
Expert II

The I2C protocol requires that a NAK is received to stop transmission. So there will be no workaround that confirms I2C.

What is your actual problem causing, can you tell us a bit more (upload project??)?

Bob

View solution in original post

0 Likes
Reply
MotooTanaka
Esteemed Contributor

Hi,

May be sending to non-exist slave is not an easy task.

How about add another I2C in your device as a slave and let it pretend the slave you are planning to use later?

I tested with following set up.

000-schematic.JPG

main() is something like

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

int main(void)

{

    int tmp ;

    int byteCount = 0 ;

    int i ;

    init_hardware() ;

  

    splash() ;

    prompt() ;

    for(;;) {

        if (get_string(str) > 0) { /* received normal string */

            sscanf(str, "%x", &tmp) ;

            m_tx_data[0] = tmp & 0xFF ;

            print("Master sending:") ;

            sprintf(str, "0x%02X\n", m_tx_data[0]) ;

            print(str) ;

          

            I2CM_MasterClearStatus() ;

            I2CM_MasterWriteBuf(i2c_slave_address, m_tx_data, 1, I2CM_MODE_COMPLETE_XFER) ;

            while((I2CS_SlaveStatus() & I2CS_SSTAT_WR_CMPLT) == 0)

                ;

          

            byteCount = I2CS_SlaveGetWriteBufSize() ;

            sprintf(str, "Slave Received:[%d]", byteCount) ;

            print(str) ;

          

            I2CS_SlaveClearWriteStatus() ;

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

                sprintf(str, " 0x%02X", s_write_data) ;

                print(str) ;  

            }

            print("\n") ;

            I2CS_SlaveClearWriteBuf() ;

            prompt() ;

        }

    }

}

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

Then I could send data from I2CM (Master) to I2CS (slave)

001-TeraTerm-log.JPG

For the details please refer to the datasheet of the component.

Attached is my sample project using CY8CKIT-059.

moto

0 Likes
Reply