cancel
Showing results for 
Search instead for 
Did you mean: 

Problem waking from Stop Mode 2 using LPUART

Clonimus74
Senior II
Posted on November 07, 2017 at 12:49

The original post was too long to process during our migration. Please click on the attachment to read the original post.
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on February 11, 2018 at 13:50

Seems I found the problem.

The CubeMX generated code enters the 'default' trimming value for the HSI, which is according to the datasheet and CubeMX 0x10 (16).

LL_RCC_HSI_SetCalibTrimming(16);

This causes large deviations of the clock and so the baud rate is off and frame error occurs.

If I mask this line in the code I see the

default value is actually 0x40 and not 0x10

 

(HSITRIM in ICSCR), and in this case all functions well.

I will add a discussion regarding this to see STs comment.

View solution in original post

4 REPLIES 4
Clonimus74
Senior II
Posted on November 09, 2017 at 12:36

no one is able to help?

Posted on February 11, 2018 at 13:50

Seems I found the problem.

The CubeMX generated code enters the 'default' trimming value for the HSI, which is according to the datasheet and CubeMX 0x10 (16).

LL_RCC_HSI_SetCalibTrimming(16);

This causes large deviations of the clock and so the baud rate is off and frame error occurs.

If I mask this line in the code I see the

default value is actually 0x40 and not 0x10

 

(HSITRIM in ICSCR), and in this case all functions well.

I will add a discussion regarding this to see STs comment.

Posted on March 24, 2018 at 14:36

May I trouble you with a quick q?

i have a new application that spends most of its time in STOP2 mode, but also needs to accept inbound comms at 9600bps reliably.  It doesn’t matter how much power it takes or what clock is used once awakened, but inbound 9600bps comms must be reliable with no dropped chars or framing errors.

i have an stm32l4+ prototype board, and for the life of me I cannot get it to wake from stop2 on lpuart reception.  Nor can I find sample code or guidelines; your code above seems the best that I’ve been able to find, and it still doesn’t work for me. I must say that I am totally unclear on what needs to be re-enabled manually after wake up, since I had assumed that all clocks/etc were just restarted automatically when it wakes into run mode.

i have not yet tried setting the trim, but before I do, I just have a couple basic questions:

- can lpuart1 be configured as above, using hsi, to reliably wake up and receive at 9600bps? (If so, is there an example project lying around somewhere that I can test and adapt?)

- or, alternatively, must I redesign my board to have an external crystal and thus use LSE for lpuart1?

This is kind of a time sensitive question because I have a 1 week deadline for design changes on the next rev of the board.

thanks much for your generous assistance.

Posted on March 25, 2018 at 13:56

Yes, 9600 can wake the LPUART reliably without losses of bytes, I managed to have it work with 115

HSI will work fine, I use HSI. LSE limits you to 9600 if I'm not mistaken.

The thing I've noticed is that if the wakeup clock of the system after waking from Stop Mode is different than the clock used for LPUART, you must re-enable the clock. For example, in my system theclock the system uses after wakeup is MSI and the LPUART uses HSI so in the interrupt I must re-enable HSI.

See my post

https://community.st.com/0D50X00009XkW1lSAF

about this issue.

Hope that helps