2016-05-26 04:44 AM
STM32F051
I get a Hard fault when I try to read the uinque Id ''Unique device ID register (96 bits) The 96-bit unique device identifier... provides a reference number which is unique for any device and in any context. These bits cannot be altered by the user. Base address: 0x1FFF F7AC Address offset: 0x00 Read only = 0xXXXXXXXX where X is factory-programmed''https://techoverflow.net/blog/2015/02/03/reading-the-stm32-unique-device-id-in-c/
If I try to read another location I read it fine. Is the address actually out of range and the manual is wrong? or do I have to do some operation before I try to read it ? I also tried reading with st-link 13:36:03 : Connected via SWD. 13:36:03 : Connection mode : Normal. 13:36:03 : Debug in Low Power mode enabled. 13:36:03 : Device ID:0x440 13:36:03 : Device flash Size : 64KBytes 13:36:03 : Device family :STM32F051x4/F051x6/F051x8/F030x8 13:36:03 : Can not read memory! Thank you very much #stm32-f051x2016-05-26 07:26 AM
Hi Pares,
For IDCODE read refer to DBGMCU_IDCODE register in RM0091 ( page 921). As mentionned in page 972, you can simply do that by putting this line code:/* Read MCU Id, 32-bit access */
MCU_Id = DBGMCU->IDCODE;
-Hannibal-
2016-05-26 07:53 AM
well that works, that way I can read the device ID but its the same from the same family and type. I want to read the unique Id from ''DocID018940 Rev 8 page 933/1008'' so I can use it to differentiate devices from the same type.
Update : reading unique ID Now it works and I had debugged some HardFaults, on debug step into... and on runtime got the printf I set inside HardFault_Handler. I did call FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPERR); now it works even if I don't call that, I am not sure of the reason, I call FLASH_lock() and also reads fine which it was about flash lock unlock motive shouldn't. Ok I found the reason I somehow managed to mistype the Address and not notice it 0x1ffff7a10 is actually out of range... Sorry Hannibal and Clive2016-05-26 08:29 AM
13:36:03 : Can not read memory!
Read a more constrained block of memory, ie0x1FFFF700[0x100]printf(''STM32 %d KB FLASH, %08X-%08X-%08X UNIQUE
'',
*((unsigned short *)0x1FFFF7CC),
*((unsigned long *)0x1FFFF7AC),
*((unsigned long *)0x1FFFF7B0),
*((unsigned long *)0x1FFFF7B4) );
If it Hard Faults, then you need to evaluate what exactly is faulting, the processor provides specific details, review them, understand the cause.
There are some F0 family parts that do not support the Unique ID, your's is documented too unless it has been remarked.
2016-05-26 09:17 AM
Hi Pares,
I have made a quick test using ST-Link utility to read the address on STM32F053B-DISCO and it is successful. -Hannibal-