1
\$\begingroup\$

I have stm32l100 and stm32l152 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 with LED blinking ST's 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'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.

UPDATE: 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? Thanks.

UPDATE2: Now I tried to do exactly the same steps using HAL library and it works (previously I used ST's cubemx blinking example), so it looks like a bug? I had some problems registering at ST's site so I wrote here first, but now it works, so I'm writing also there - will add link.

UPDATE3: link to my question on ST forum: https://community.st.com/message/177130

UPDATE4: so here is the code, if somebody wants to look at it, but as I said it's basic projecte generated in cubemx with added pin toggling: https://drive.google.com/open?id=1cMD3MVGXOofLq63syTW1itVMJL3xaIMh

\$\endgroup\$
1
\$\begingroup\$

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).

\$\endgroup\$
0
\$\begingroup\$

This happens on both boards and when I flash them with LED blinking ST's example it works, so it should be some firmware problem and I would say some initialization problem.

As I can understand, you are having a problem debugging the code but the code itself is working perfectly! So, I would ask you to check whether you have enabled the Debug option in Systick or not!? Have you tried putting LL_FLASH_SetLatency(LL_FLASH_LATENCY_2); before the voltage configuration as pointed in the link given by you? Also, check and backtrace complete ll_library whether everything is properly configured or not!

In general, it would be good if you can post your code especially all the configurations. If you are looking for more information on flash_latency refer this post

\$\endgroup\$
  • \$\begingroup\$ Thank you - but I have to clarify. ST's example from cubemx package is based on HAL - this one and also one I create using cubemx (choosing board, setting project name and IDE and generating) works too. So HAL works, but LL (the same settings as generated by me in cubemx only changing library to LL) doesn't. I didn't set debug option in Systick - at least am not aware of it, I don't know what it is. When I change LL_FLASH_LATENCY_1 to LL_FLASH_LATENCY_2 it does not compile as LL_FLASH_LATENCY_1 isn't defined (I use L1 based boards, he talks about L4). I'll post my code. I'll look at the link. \$\endgroup\$ – upratathlavu Dec 1 '17 at 14:02
  • \$\begingroup\$ For board specific answers, ST_forums would be better. What I can still suggest you is to backtrace the entire library till the file where LL_FLASH_LATENCY_1 is defined. From this link, it seems that Cubemx has no good integration for LL libraries or still in making. \$\endgroup\$ – charansai Dec 1 '17 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.