Hardfault, when reading TEMPSENSOR_CAL1_ADDR with STM32H56x
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-26 1:10 AM - edited ‎2025-04-26 1:52 AM
#define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x08FFF814UL)) /* Address of parameter TS_CAL1: On STM32H5,
temperature sensor ADC raw data acquired at temperature 30 DegC
(tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
uint16_t regval = *TEMPSENSOR_CAL1_ADDR;
as soon as this address is read, the CPU goes into Hardfault. I double checked the Address in the Datasheet..
also restarts the CPU, when I try to show this Memory with the debugger.
also tested it with a Nucleo-H563ZI.
the same access with other STM32 CPUs (U5, L4 etc) work with no problems.
Solved! Go to Solution.
- Labels:
-
STM32H5 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-26 2:48 AM
Hi,
its a problem with the cache : disable cache, then see:
int flsz = FLASH_SIZE;
printf("size : %d \n", flsz);
int regval = *TEMPSENSOR_CAL1_ADDR;
printf("tempcal1 %ld C : %d \n", TEMPSENSOR_CAL1_TEMP, regval);
To be able to read into system flash you need to disable the cache associated to this area.
This can be done by setting non cacheable attribute this this region.
You have an example for accessing this UID in the STM32CubeH5 here:
STM32Cube_FW_H5_V1.3.0\Projects\NUCLEO-H563ZI\Examples_LL\UTILS\UTILS_ReadDeviceInfo\
(by Jocelyn R.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-26 2:48 AM
Hi,
its a problem with the cache : disable cache, then see:
int flsz = FLASH_SIZE;
printf("size : %d \n", flsz);
int regval = *TEMPSENSOR_CAL1_ADDR;
printf("tempcal1 %ld C : %d \n", TEMPSENSOR_CAL1_TEMP, regval);
To be able to read into system flash you need to disable the cache associated to this area.
This can be done by setting non cacheable attribute this this region.
You have an example for accessing this UID in the STM32CubeH5 here:
STM32Cube_FW_H5_V1.3.0\Projects\NUCLEO-H563ZI\Examples_LL\UTILS\UTILS_ReadDeviceInfo\
(by Jocelyn R.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-26 4:16 AM
Thank you so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-27 10:12 PM
/* Disable MPU before perloading and config update */
LL_MPU_Disable();
/* Define Not cacheable memory via MPU */
LL_MPU_ConfigAttributes(LL_MPU_ATTRIBUTES_NUMBER1, LL_MPU_NOT_CACHEABLE);
/* BaseAddress-LimitAddress configuration for RO area*/
LL_MPU_EnableRegion(LL_MPU_REGION_NUMBER1);
LL_MPU_ConfigRegion(LL_MPU_REGION_NUMBER1,LL_MPU_REGION_ALL_RO,LL_MPU_ATTRIBUTES_NUMBER1, 0x08FFF800UL, 0x08FFFFFFUL);
/* Enable MPU */
LL_MPU_Enable(LL_MPU_CTRL_HFNMI_PRIVDEF);
Why not add these lines of code through CubeMX if cache is enabled?
Would prevent some hardfaults
