0

I am Using STM32F767ZI MCU on Nucleo 144 board, C++ as programming language and IAR embedded workbench IDE. TXIS bit flag Status is never getting Set (1) even when the I2C is enabled and there is no data in TXDR register.

What I have also noticed that although both master and slave have same Slave address in the relevant registers but NO ADDCODE occurs. Although as evident from code I am using the Polling method. ADDCODE register should have same address as slave address which is not happening as well.

Hardware settings have been verified as correct.

Trying to perform Loopback test on same MCU using I2C1 as master transmitter and I2C2 as slave receiver. Code is getting stuck at part as below:

while(!(IsTXISset())) // Code is getting stuck here
{

}

Where IsTXISset() is as below:

bool I2CInterface_c::IsTXISset(void) const
{
    bool flag{false};
    volatile uint32_t isrreg = I2C_ISR.Get();

    isrreg &= TXISFLAG; //TXISFLAG = 0x02 i.e the only bit position of the TXIS is set as high
    if(isrreg == TXISFLAG)
    {
        flag = true;
    }
    return flag;  

}

Can Anybody assist with that please?

A 786
  • 488
  • 1
  • 6
  • 16
  • Could you provide a minimum compilable example? That way someone with the board can actually try it. It will also include the setup code, which might be missing something in this particular case. – domen Sep 05 '18 at 14:32
  • Are the pull up resistors on your board? – Mike Sep 06 '18 at 06:52
  • I have tried both approaches 1-by using MCU's internally pulled up resistance making the sda and scl gpio pins pulled up. 2- by making gpio as no push pull in the code while using externally pull up resistors which are on the TMP102 (I2C temperature sensor)SDA and SCL line i.e 4.7k resistors on a breakout board internally. – A 786 Sep 06 '18 at 07:38
  • Let's simplify question all the initial configuration is right in code for which relevant values are going in registers . If someone can share simple logic for transmitting data from master to slave that would be very helpful. – A 786 Sep 06 '18 at 21:13
  • @domen due to copyright issues I cannot share full code but any specific routine I can just mention flow if that helps? – A 786 Sep 06 '18 at 21:15
  • You're not falling into the age-old trap caused by 7-bit slave addresses are you? – Ed King Sep 11 '18 at 19:57

1 Answers1

0

Finally, managed to resolve the issue after noticing that GPIO pins were not setting up properly in Alternative function open drain mode. Second problem identified after slave started acknowledging the address match no data transfer was taking place which got resolved by writing a routine to clear the ADDR bit is ISR register of I2C.

A 786
  • 488
  • 1
  • 6
  • 16