LPC812: Powering down process of PLL

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC812: Powering down process of PLL

1,234 次查看
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

标签 (3)
0 项奖励
回复
2 回复数

1,111 次查看
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 项奖励
回复

1,111 次查看
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 项奖励
回复