Skip to main content
BSpoe.1
Associate III
March 5, 2020
Question

[BUG] STM32WB55 Code Generation with CubeMX - HAL configuration

  • March 5, 2020
  • 3 replies
  • 1080 views

Hi,

I have some problems with the code generation in CubeMX. In the HAL_Init() are three defines checked for enabling or disabling the flash instruction cache, the flash data cache and the prefetch buffer. The default configuration says the following:

/* Configure Flash prefetch, Instruction cache, Data cache */
/* Default configuration at reset is: */
/* - Prefetch disabled */
/* - Instruction cache enabled */
/* - Data cache enabled */
#if (INSTRUCTION_CACHE_ENABLE == 0U)
 __HAL_FLASH_INSTRUCTION_CACHE_DISABLE();
#endif /* INSTRUCTION_CACHE_ENABLE */
 
#if (DATA_CACHE_ENABLE == 0U)
 __HAL_FLASH_DATA_CACHE_DISABLE();
#endif /* DATA_CACHE_ENABLE */
 
#if (PREFETCH_ENABLE != 0U)
 __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
#endif /* PREFETCH_ENABLE */

I have checked this with the preconfiguration inside CubeMX. The default settings are correct. But after generation I can find an activated prefetch buffer in the HAL config file:

#define PREFETCH_ENABLE 1U
#define INSTRUCTION_CACHE_ENABLE 1U
#define DATA_CACHE_ENABLE 1U

So the prefetch buffer is enabled. I cannot change this value inside the file stm32wbxx_hal_conf.h to the correct value. When I change the value to 0 nothing happens.

What can I do to disable this without uncomment the function? Is there anything to change for the project for using the correct setting after changing the value in the HAL config file?

Thanks a lot,

Ben

This topic has been closed for replies.

3 replies

Remi QUINTIN
Technical Moderator
March 5, 2020

If I look carefully in the extract of the stm32wbxx_hal.c file you show, the prefetch buffer is already enabled in the start configuration set it the HAL_init function.

This activation is based on the #define PREFETCH_ENABLE            

So it is the other way round: #PREFETCH_ENABLE   is not resulting from the call to the _HAL_FLASH_PREFTECH_BUFFER_ENABLE function.

What is strange is the fact that setting PREFETCH_ENABLE  to 0 does not disable this prefetch buffer.

Did you properly rename the file stm32wbxx_hal_conf_template.h by the name other files include it which is stm32wbxx_hal_conf.h

In the end, if you really want to disable it, you can call the __HAL_FLASH_PREFETCH_BUFFER_DISABLE() macro available in the stm32wbxx_hal_flash.h file.

Could you tell me why you want to disable this prefetch buffer?

BSpoe.1
BSpoe.1Author
Associate III
March 5, 2020

I just took the generated code from CubeMX without any modification. I didn't use the template file for configuration.

When I started with the STM32WB55 controller I read something that it's not allowed to enable the prefetch buffer when using the standby mode for lowest power consumption. In my project I need the lowest consumption that is possible. And inside the example project of the p2pServer for the USB dongle it's also disabled.

Remi QUINTIN
Technical Moderator
March 5, 2020

​>I didn't use the template file for configuration.

You don't have to use it as such but you have to modify it with your own configuration and rename it stm32wbxx_hal_conf.h as it the name use by all the other files to include it.

Or use the __HAL_FLASH_PREFETCH_BUFFER_DISABLE() function to disable it for sure.