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

Reading a write only register value

What's the expected behavior when reading a register that is write only? For example, I'm using an some code that is reading the value of the TASK_START register of the RNG (nRF52832).

I'm expecting this to be unpredictable so I'm surprised to see this code.

Parents
  • This code looks strange to me and seems that it depends on the undefined behavior. Atleast when using KEIL which reads the registers open in the new constantly, even though writing '1' to any TASKS never shows the register to be '1'. Which implicitly means that this register should always read 0. I do not have the hardware in hand to verify this, but it should be easy to verify this. Pseudocode

    volatile uint32_t verify = 0;
    NRF_RNG->TASKS_START = 1;
    verify = NRF_RNG->TASKS_START;
    print verify
    
Reply
  • This code looks strange to me and seems that it depends on the undefined behavior. Atleast when using KEIL which reads the registers open in the new constantly, even though writing '1' to any TASKS never shows the register to be '1'. Which implicitly means that this register should always read 0. I do not have the hardware in hand to verify this, but it should be easy to verify this. Pseudocode

    volatile uint32_t verify = 0;
    NRF_RNG->TASKS_START = 1;
    verify = NRF_RNG->TASKS_START;
    print verify
    
Children
No Data
Related