cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 SMBus Transmitt address but does't do command

rsharifi9
Associate III
Posted on November 20, 2017 at 20:16

dear ST Community,

i am trying to talk to a smart battery through SMBus as bellow:

to initialize: an I2C of the STM32F407 as SMBus.

to transmit battery address ( slave )

to acknowledge from it

but the command doesn't be send to the battery!

does any body have experience in?

thanks in advance.

the code is here:

hi2c1.Instance->CR1 |= I2C_CR1_START;

    if (I2C_WaitOnFlagUntilTimeout(&hi2c1,I2C_FLAG_SB,1,1,0)== 1) {}; // wait on generation

    

    // read sr1

    sr1or2=hi2c1.Instance->SR1;

    for ( i1=1;i1<20;i1++) {        __NOP;} // wait for read complete

        

    // address

    hi2c1.Instance->DR=0x16; // battery address : 0x16 + 0 ( write )

                

                        

    // ack 1

    

                

                //EV6        

    if ( I2C_WaitOnMasterAddressFlagUntilTimeout(&hi2c1,I2C_FLAG_ADDR,1,0) == 1 ) {}

    

        // read sr1 and sr2

        sr1or2=hi2c1.Instance->SR1;

        sr1or2=hi2c1.Instance->SR2;

        if (I2C_WaitOnFlagUntilTimeout(&hi2c1,I2C_FLAG_ADDR,0,1,1)== 1) {}; // // wait for clear addr

                      

        //EV8_1

        if (I2C_WaitOnTXEFlagUntilTimeout(&hi2c1,25,0)== 1) {} // wait for TxE be set

      

        

            for ( i1=1;i1<10;i1++) {        __NOP;} // wait for read complete

      

            

    // command ( data 1 )

        

            

            hi2c1.Instance->DR=0x08; // command 0x8 : temperature

...

#smbus #smart-battery #read-word-protocol #stm32f4
0 REPLIES 0