cancel
Showing results for 
Search instead for 
Did you mean: 

How wake up from I2C when I enter STOP mode?

starlin lin
Associate II
Posted on December 07, 2017 at 05:59

Thx for reading,

I am using I2C of STM32L476, and have one Master , two Slave device.

Slave1 will go into STOP mode, and need wake up by I2C.

Slave2 not be polling by Master every 100ms.

But after Slave1 into STOP mode, and Master polling Slave2 again,

The SCL will lock at low level,

0690X000006095iQAA.png

Then, I can't wake up Slave1 by I2C, any one know why the SCL will lock at low level??

BTW, I already have reference the example code:

STM32Cube_FW_L4_V1.8.0/Projects/STM32L476RG-Nucleo/Examples/I2C/I2C_WakeUpFromStop

STM32Cube_FW_L4_V1.8.0/Projects/STM32L476RG-Nucleo/Examples/I2C/I2C_WakeUpFromStop2

My code as below: (almost same as example code by I2C_WakeUpFromStop)

I2cHandle.Instance = I2C1;

I2cHandle.Init.Timing = I2C_TIMING;

I2cHandle.Init.OwnAddress1 = 0x05;

I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;

I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;

I2cHandle.Init.OwnAddress2 = 0xFF;

I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;

I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;

HAL_Init();

SystemClock_Config();

if(HAL_I2C_Init(&I2cHandle) != HAL_OK){}

HAL_I2CEx_ConfigAnalogFilter(&I2cHandle,I2C_ANALOGFILTER_ENABLE);

HAL_I2CEx_EnableWakeUp(&I2cHandle);

//if I mark this line the SCL will not lock at low level

if(HAL_I2C_Slave_Receive_IT(&I2cHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK){}

HAL_RCCEx_WakeUpStopCLKConfig(RCC_STOP_WAKEUPCLOCK_HSI);

__HAL_RCC_PWR_CLK_ENABLE();

fw_info(''i2c CR1 %x'' CRLF,I2C1->CR1);

fw_info(''i2c ISR %x'' CRLF,I2C1->ISR);

HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

and My register value as below:

i2c CR1 400fd

i2c ISR b0001
0 REPLIES 0