Showing results for 
Search instead for 
Did you mean: 

i2c and stop mode

Posted on October 30, 2016 at 23:31

I'm using Nucleo-STM32L053R8 and trying to get I2C slave mode to work along with stop mode.  I'm using interrupt mode for the I2C.  I'm using I2C1.  I'm using HSI16 for I2C1 and the CPU.

1st attempt: I want I2C slave to wake up the MCU when it's stopped.  It works one time (CPU wakes up after one transaction).  But then something strange happens if I try to set up for another transaction with a call to HAL_I2C_Slave_Receive_IT: the MCU appears to stop while in this call!  I mean I've not yet called HAL_Pwr_EnterSTOPMode, but the CPU seems to have stopped or is in some weird state.  Another I2C transaction will ''unstuck'' it.  Other events do not (for example, I also have the LPUART set to wake up from stop, but it does not in this case).

2nd attempt: give up on I2C wake up (Instead use a pin to wake up the CPU before trying I2C).  But now I have a different problem.  The I2C1 does not seem to survive entering and exiting STOP mode (meaning it will not respond to the I2C transactions after the first STOP).  I've tried surrounding the EnterSTOPMode with I2C_DeInit and I2C_INIT, but no luck.  I'm doing this because I see this note in the errata ''Disable the I2C interface (PE=0) before entering Stop mode and enable it again in Run mode.''  This is a note for ''I2C peripheral limitations'' section.

Has anyone gotten I2C slave to play along with STOP mode?  Any hints?  I'm about to switch to another chip because of this.

Nesrine M_O
Lead II
Posted on November 02, 2016 at 11:38

Hi allen.joseph.001,

I recommend you to have a look to this example under STM32L0 cube firmware package it may be helpful: