cancel
Showing results for 
Search instead for 
Did you mean: 

Instruction Cache and Prefetch Buffer Settings are ignored if only LL library is used

eos1d3
Associate III

When using HAL library, HAL_Init has init code:

#if (INSTRUCTION_CACHE_ENABLE == 0U)

__HAL_FLASH_INSTRUCTION_CACHE_DISABLE();

#endif /* INSTRUCTION_CACHE_ENABLE */

#if (PREFETCH_ENABLE != 0U)

__HAL_FLASH_PREFETCH_BUFFER_ENABLE();

#endif /* PREFETCH_ENABLE */

 

But when using ONLY LL library, these two settings are ignored. Enabling or disabling the two settings generates the same code. Please fix it.

3 REPLIES 3
FBL
ST Employee

Hi @eos1d3 

Which STM32 product are you using? Did you check HAL system configuration in stm32xx_hal_conf.h file. You may check definitions in this file rather than in toolchain compiler preprocessor.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


eos1d3
Associate III

Hi,

I am using STM32G03x. As I said earlier, to test this, please do NOT use any HAL components, just use only Low Level library. So stm32xx_hal_conf.h is not generated and there is no such file in the STM32Cube project.

Screenshot 2024-07-02 at 19.10.02.png

 

When you change Prefetch Buffer and Instruction Cache in the above screen. Their values are updated in .project and .mxproject. But there is no initialization codes to use the values. So these settings are always power on default values.

If you use any HAL library, HAL_Init will be generated and there are initialization codes (in my first post) for these settings.

So using pure Low Level library, the Prefetch Buffer and Instruction Cache initialization codes are missing. The missing part is listed below. Code generation should add these code to main() if HAL is not used.

int main(void)
{
  /* USER CODE BEGIN 1 */
/* Configure Flash prefetch, Instruction cache             */
/* Default configuration at reset is:                      */
/* - Prefetch disabled                                     */
/* - Instruction cache enabled                             */


#if (INSTRUCTION_CACHE_ENABLE == 0U)
LL_FLASH_DisableInstCache();
#endif /* INSTRUCTION_CACHE_ENABLE */


#if (PREFETCH_ENABLE != 0U)
LL_FLASH_EnablePrefetch();
#endif /* PREFETCH_ENABLE */
  /* USER CODE END 1 */

....

}


the_mild_one
Associate

I have found the same problem configuring a STM32F405 project using the low level interface only.

Regardless of the settings of 'Instruction cache'/'Data cache'/'Prefetch buffer' no code is generated to apply these settings.

As a drawback the ADC is not working as expected.

I kindly ask to fix this bug. Even after 15+ years of working with the STM32 family it was hard to figure out the reason why a peripheral is not working as specified if these settings are not done properly.

 

Thanks, Andreas