Read values of UICR in Application

Hi, 

I am trying to read the value of the UICR register CUSTOMER[4] during the runtime of the application. Therefore, I am using the following code:

nrf_fstorage_read(&m_fs, (0x10001090), &destination, 32);

Where m_fs is the storage instance and destination is initialized as a char array.

My two questions are: 

- Is it correct to use nrf_fstorage_read for this purpose?

- Which address do I need to use, as my call is returning error 16: NRF_ERROR_INVALID_ADDR

Thanks, 

Simon

Parents
  • Hi,

    You cannot use fstorage in this case. To read data from the UICR (or any other fixed address in flash for that matter), just read it directly. Example:

    uint32_t reg_val = *(volatile uint32_t *) 0x10001090;

    Here, the content of CUSTOMER[4] will be copied to the variable reg_val. You could also make a pointer and use that. For example, like this:

    volatile uint32_t * p_my_uicr_reg = (volatile uint32_t *) 0x10001090;
    NRF_LOG_INFO("Val: %08X", *p_my_uicr_reg);

Reply
  • Hi,

    You cannot use fstorage in this case. To read data from the UICR (or any other fixed address in flash for that matter), just read it directly. Example:

    uint32_t reg_val = *(volatile uint32_t *) 0x10001090;

    Here, the content of CUSTOMER[4] will be copied to the variable reg_val. You could also make a pointer and use that. For example, like this:

    volatile uint32_t * p_my_uicr_reg = (volatile uint32_t *) 0x10001090;
    NRF_LOG_INFO("Val: %08X", *p_my_uicr_reg);

Children
Related