cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L100RC and STM32L152RC disco boards fail on LL_FLASH_GetLatency() != LL_FLASH_LATENCY_1

upratat hlavu
Associate
Posted on November 30, 2017 at 22:31

Hallo all, I'm not sure, but maybe I found a bug - I wrote this question at stackexchange.com first, because I had problems to create account here, but now it works so I'm writing here (link to my stackexchange post:

https://electronics.stackexchange.com/questions/342643/stm32l100rc-and-stm32l152rc-disco-boards-fail-on-ll-flash-getlatency-ll-fla

).

My problem:

I have stm32l100rc and stm32l152rc disco boards and am using stm32cubemx and sw4stm32 IDE.

After creating default project for them in cubemx - I mean I go through board chooser and then leave everything as is except changing library from HAL to LL in project -> settings -> advanced settings for both RCC and GPIO and generate project for sw4stm32 - I import it to sw4stm32, add some code for LED3 blinking (to while loop in main function):

LL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);LL_mDelay(1000);

build it and run it (it's written to board, I see status LED blinking), but LED3 does not blink.

When I run it in debug mode and step the code it fails at line (in SystemClock_Config() function):

LL_FLASH_GetLatency() != LL_FLASH_LATENCY_1

and goes to Error_Handler() which sits in while loop forever...

This happens on both boards and when I flash them withST's LED blinking example it works, so it should be some firmware problem and I would say some initialization problem. I read STM32CubeL1GettingStarted.pdf and there is written that I should define right macro in stm32l1xx.h - which should be STM32L100xC or STM32L152xC and I did it - or rather uncomented existing one in that file. I even tried to add it to main.c file - it didn't help. And I tried to do it with and without this macro defined.

The only close question I found is this

https://community.st.com/thread/15501

- but in v 1.8.0 of cubemx library this seems to be in right place.

I even tried to generate project with older version of LL libraries (1.7.0 and 1.6.0), but still no progress.

Does anybody at least have some tutorial for blinking leds (or manipulating with GPIO) on L1 processors using LL library based on cubemx generated project? Or could somebody send me working led blinking (gpio manipulating) code for STM32L100RC or STM32L152RC generated in cubemx using LL library?

I also tried to do exactly the same steps using HAL library and it works (previously I used ST's cubemx blinking example), so is this a bug?

I'm quite noob to these boards and have experience only with arduino so all this setup is quite overhelming for me right now and don't know where the cause could lie... so if anybody could direct me I would apreciate it really much.

1 ACCEPTED SOLUTION

Accepted Solutions
upratat hlavu
Associate
Posted on December 06, 2017 at 00:16

Ok, I think I found it - as stated in HAL & LL manual for L1 at page 1088 for LL_FLASH_SetLatency function:

> Latetency can be modified only when ACC64 is set. (through function

> LL_FLASH_Enable64bitAccess)

And this function call is missing in generated cubemx project. I found it, when I looked at LL GPIO example for stm32l152re nucleo board (as there is no LL example for stm32l100rc and stm32l152rc disco boards), where this function is used.

Adding it before LL_FLASH_SetLatency in SystemClock_Config solved it, and the LED now blinks (at least at l100 board, didn't try l152 yet).

View solution in original post

1 REPLY 1
upratat hlavu
Associate
Posted on December 06, 2017 at 00:16

Ok, I think I found it - as stated in HAL & LL manual for L1 at page 1088 for LL_FLASH_SetLatency function:

> Latetency can be modified only when ACC64 is set. (through function

> LL_FLASH_Enable64bitAccess)

And this function call is missing in generated cubemx project. I found it, when I looked at LL GPIO example for stm32l152re nucleo board (as there is no LL example for stm32l100rc and stm32l152rc disco boards), where this function is used.

Adding it before LL_FLASH_SetLatency in SystemClock_Config solved it, and the LED now blinks (at least at l100 board, didn't try l152 yet).