cancel
Showing results for 
Search instead for 
Did you mean: 

wake up from stop mode using I2C on X revision

Damiano Balzani
Associate III
Posted on March 20, 2018 at 10:46

Hi everybody,

I'm trying to wake up the MCU 

STM32L051T6

from stop mode using I2C.

i saw that it is a very common problem.

i read the errata sheet and it reports tha on X revision the problem is fixed.

Now i'm using the revision X.

My target is to wake up by an address match. This is the code:

void stopMode(void)

{

LL_I2C_ClearFlag_OVR(I2C1);

// Make sure that no I2C transfer is on-going

while(LL_I2C_IsActiveFlag_BUSY(I2C1) == 1)

{

}

DBGMCU -> CR |= DBGMCU_CR_DBG_STOP;

// Set I2C1 clock source as HSI

RCC -> CR |= 0x00000002; //Enable HSIKERON clock on stop mode

LL_RCC_SetI2CClockSource(LL_RCC_SYS_CLKSOURCE_HSI);

LL_I2C_ConfigFilters(I2C1, LL_I2C_ANALOGFILTER_DISABLE, 0x00);

LL_I2C_EnableWakeUpFromStop(I2C1);

LL_I2C_EnableClockStretching(I2C1);

NVIC_SetPriority(I2C1_IRQn, 0);

NVIC_EnableIRQ(I2C1_IRQn);

PWR->CR |= PWR_CR_CWUF; // clear the WUF flag after 2 clock cycles

PWR->CR &= ~( PWR_CR_PDDS ); // Enter stop mode when the CPU enters deepsleep

RCC->CFGR |= RCC_CFGR_STOPWUCK; // HSI16 oscillator is wake-up from stop clock

SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; // low-power mode = stop mode

__WFI(); // enter low-power mode

}

it goes in Stop mode.

when i try to send an'I2c message the SCL goes down for ever. I can't send the address.

Can somebody help me?

I hope that this discussion will be useful for the community

Thanks 

Damiano

#wake-up #i2c-bug #exit-stop
0 REPLIES 0