[En-Nut-Discussion] FRC: Direct or Pointer
ulrich.prinz at googlemail.com
Sun Nov 13 19:03:29 CET 2011
Am 13.11.2011 16:04, schrieb Nathan Moore:
> My referred way of dealing with this is to make local copies of the
> variables I need at the start of the function and write the ones that may
> have changes back out at the end of the function. When this can be done it
> lets the compiler optimise most of the code as access to local and
> exclusively owned variables, but there are some cases where this can't be
That is exactly the way to go and I used that one in many of the Cortex
port things. You can see it in the PLL setup or in the other low level
First get myctl = PLL->PLL_CONTROL_REG, then and/or/xor myctl.
Then if that / else if that / else with the myctl. At the end
PLL->PLL_CONTROL_REG = myctl.
This additionally avoids spurious things on the devices them selfs. One
of the needed register modification might already change things that are
connected to the outer world and that might be something you donÄt want
to happen. So assemble the registers shadow variable completely before
writing it back to the register itself.
More information about the En-Nut-Discussion