This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Entering BusFault_handler when checking NRF_NVMC->READY

Hello,

When line 10 of the below code is executed the system enters the BusFault_Handler, at this point the NVMC register is as followed: Ready = 0x00000001, Config = 0x00000001, the rest of the register is set to 0's.

1:  NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
2:
3:  while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
4:  {
5:     /* Do nothing. */
6: }
7:
8: *address = value;
9:
10: while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
11: {
12:   /* Do nothing. */
13: }
14:
15: // Turn off flash write enable and wait until the NVMC is ready:
16: NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
17:
18: while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
19: {
20:   // Do nothing.
21:}

Any idea why this is happening?

Thanks

Parents
  • It looks like everything you are doing with the NVMC is correct. So I think your problem is *address = value; My first question is what is the value of address? It would need to be a multiple of 4, word aligned, (i think trying to write to address 0x01 would give you a hardfault). Also what is address's type? It should be uint32_t * address (it needs to be a pointer to an unsigned 32 bit value). Last it needs to be a valid address in the memory map (either flash, uicr or ram). Also value should probably be of type uint32_t to be safe. If you are simplifying the memory write for this question be very careful of pointer arithmetic. (when you increment a pointer to a memory word does its value change to the next word in memory (i.e. 0x0 -> 0x4) or does it just increment the raw value (0x0 -> 0x1)?

  • I cant seem to mark this as the answer, but it is the answer. Some of the addresses i was using weren't divisible by 4.

Reply Children
No Data
Related