Hi,
In LPCOpen, below is the function that Power downs the PLL.
Why they are powering down the PLL this way ?
They could have used below method:
LPC_SYSCTL->PDRUNCFG |= powerdownmask
where powerdownmask = 0x80 (argument to this function. This method is simple right ?
Hi karthik venkatesh,
I agree with Marc.
Actually, if you just | 0x80, it also works, this is the just write style, more stable write style.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
I don't use LpcOpen but I'm sure they do it like that because of bits 8..14 and mayby also bits 16..31. These have to be written as the bit pattern mentioned in the table (and 0 for the upper 16bits). Somewhere in the manual you can find something like: "reserved bits are undefined when read and should be written as zero". I hate this, too, because in many cases it defeats using simple expressions like your suggestion.
Another point of course is coding style. Why should we create a local variable and do the bit manipulations on that local variable instead of simply writing
LPC_SYSCTL->PDRUNCFG = (LPC_SYSCTL->PDRUNCFG | powerdownmask)
& PDWAKEUPDATMASK
| PDWAKEUPWRMASK
;
That way, you could 'feel' that they're removing some bits (the undefined ones) and add some others (the bit patterns 8..14 I guess).
I could never make friends with 'embedded programming' coding style .-)