You are here

I2C fails after fail on I2C_MasterSendStart | Cypress Semiconductor

I2C fails after fail on I2C_MasterSendStart

Summary: 1 Reply, Latest post by Bob Marlowe on 09 Dec 2015 11:38 PM PST
Verified Answers: 0
Last post
Log in to post new comments.
ngel's picture
1 post
I'm using the I2C block as master (version 3.50).
After sending I2C_MasterSendStart to the wrong address and missing Ack:
1. I2C_MasterSendStart  returns I2C_MSTR_NO_ERROR, which is not true.
2. The second command is "I2C_MasterWriteByte", and it's stuck in:
        /* Wait until data byte has been transmitted */
included the scope catpure.
Here is very simple code demonstrate it:

    uint8 state = 0;
    uint8 dev_id = 0;
    uint8 wBuffer[2] = {1,2};

    /*Enable Global Interrupts */

    for (dev_id=5 ; dev_id<0xff ; dev_id++)
        state = I2C_MasterSendStart(dev_id, 0);    //always returns I2C_MSTR_NO_ERROR
        if (state != I2C_MSTR_NO_ERROR)
            state = I2C_MasterClearStatus();
            state =  I2C_MasterWriteByte(0x00);  // stuck here every time
            state =  I2C_MasterSendRestart(dev_id, 1);
            wBuffer[0] = I2C_MasterReadByte(I2C_ACK_DATA); 
            wBuffer[1] = I2C_MasterReadByte(I2C_NAK_DATA); 

user_1377889's picture
9288 posts

When you got stuck, the variable state must show an error (state != I2C_MSTR_NO_ERROR). You get stuck because you continue accessing the I2C



Log in to post new comments.