可能是一个很浅显的问题,不过我的确不知道,还请明白人指点一下,谢谢。
用户手册中说,时钟寄存器配置之前需要先“解锁”,即CSCTL0的CSKEY位写入0xA5。其描述是这样的:
CSKEY password. Must always be written with A5h; a PUC is generated if anyother value is written. Always reads as 96h. After the correct password is written, all CS registers are available for writing.
如果写入其他值,则产生一个PUC(Power-up clear)。
但是官方例程却是这样的:
// Startup clock system with max DCO setting ~8MHz
CSCTL0_H = CSKEY >> 8; // Unlock clock registers
CSCTL1 = DCOFSEL_3 | DCORSEL; // Set DCO to 8MHz
CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
CSCTL0_H = 0; // Lock CS registers
最后一句按照“用户手册”,不是应该产生一个PUC吗?
灰小子:
当通过写入密码打开寄存器的写使能之后,需要向寄存器的高字节以字节写入方式写入一个非密码数据来关闭写使能。
字节写入的方式不会引发PUC
user1866843:
回复 灰小子:
谢谢。不过在User's Guide里面有提到吗?没发现啊。
user1866843:
回复 灰小子:
谢谢,我看到了。
The password defined in CSCTL0 controls access to the CS registers. After the correct password is written in word mode, write access to the CS registers is enabled. Write access is disabled by writing an incorrect password in byte mode to the CSCTL0 upper byte.