AnsweredAssumed Answered

STM32F103CBT6 CPAL I2C freezing main loop

Question asked by Morris.Neil on May 15, 2013
Latest reply on Jun 13, 2013 by Morris.Neil
Hi all,

I have been using the CPAL I2C library on a STM32F103RBT6 to communicate with an external device which works fine.

I have run the same code on a target board containing a STM32F103CBT6, I2C1 is used so I have not changed any configuration between the uC's.

The following code works on the STM32F103CBT6
                                   
uint8_t dataA[] = { 55u, 55u };
            uint8_t dataB[] = { 1u, 2u };
             
            /*  CPAL_I2C_Write */
            I2C_writeRead(&I2C_DevStructure, 0xA0, dataA, dataB, 2U, 1U);
            I2C_writeRead(&I2C_DevStructure, 0xA0, dataA, dataB, 2U, 1U);

However the code below appears to hang in the CPAL functions

                                   
uint8_t dataA[] = { 1u, 1u };
            uint8_t dataB[] = { 1u, 2u };
             
            /*  CPAL_I2C_Write */
            I2C_writeRead(&I2C_DevStructure, 0xA0, dataA, dataB, 2U, 1U);
            I2C_writeRead(&I2C_DevStructure, 0xA0, dataA, dataB, 2U, 1U);

The processor continues to run any code using interrupts as its not in the main loop with the call to I2C_writeRead.

Looking at a scope/debugger what appears to happen is on the second call to I2C_writeRead() no data is transmitted on the I2C pins and the code gets stuck looping around the I2C interrupt handler - CPAL_I2C_EV_IRQHandler()

Could there be some difference I havent seen between the STM32F103RBT6 and STM32F103CBT6 that would cause such a problem?

Any help would be much appreciated.

Outcomes