This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is it value or address?

We use NXP LPC2468 Microcontroller in our target board.

We use Keil tools to build and debug our embedded C++ application.

#define UART1_BASE_ADDR         0xE0010000
#define U1RBR          (*(volatile unsigned long *)(UART1_BASE_ADDR + 0x00))

What is contents of U1RBR ?

Is it address 0xE0010000 ?

or

Is it the value stored at address 0xE0010000.

Thank you!

Parents Reply Children
  • ANY SFR that is read should be declared volatile

    For simplicity that can be a sensible rule, but technically it is not always necessary.

    It really depends upon the purpose of what information the SFR contains and what might actually modify the value. For example, some SFRs can be used to specify the communication speed of a serial port. The underlying hardware does not change these values in the background and therefore they do not have to be declared volatile.

    Of course, something like a timer might well be changed by the underlying background (assuming that timer is enabled and active) and should be declared volatile.

  • "ANY SFR that is read should be declared volatile"

    I may have oversimplified just a tad, however none you mention are read

    For example, some SFRs can be used to specify the communication speed of a serial port. The underlying hardware does not change these values in the background and therefore they do not have to be declared volatile.