LPC812: Powering down process of PLL

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC812: Powering down process of PLL

1,228 Views
karthikvenkates
Contributor II

Hi,

In LPCOpen, below is the function that Power downs the PLL.

pastedImage_1.png

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 ?

pastedImage_2.png

Labels (3)
0 Kudos
Reply
2 Replies

1,105 Views
kerryzhou
NXP TechSupport
NXP TechSupport

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,105 Views
marcprager
Contributor III

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 .-)

0 Kudos
Reply