This example shows how to include UICR values into the application hex file. Also, it shows how to set up Keil to download and debug the generated hexfile.
The project uses uicr_config.h
to define the User Information Configuration Registers (UICR) values to be included into the hex file.
The file declares one variable per register of the UICR area and informs the linker where to place them. To include the desired value in the desired address, uncomment the variable with the proper address at the target area and update the assignment value. As shown below, the UICR register with address 0x10001080 will be assigned the value 0x12345678.
When compiling the project with the uicr_config.h stated above, it will add the section shown below into the hex. The following two lines (intel hex format) show that we have successfully generated a hex file that will fill the value 0x12345678 into the UICR address.
Note that UICR values are stored in a reserved area of the flash and should only be stored into when downloading a hex file. Do not use these defined variables to store data at run time.
You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\peripheral\uicr_config
The generated hex file will fail to download when using the standard download algorithm. Therefore, you must add a programming algorithm that handles the programming of the UICR.
To configure Keil to not use the standard download algorithm, follow these steps:
Test the UICR Configuration Example application by performing the following steps: