可能是一个很浅显的问题,不过我的确不知道,还请明白人指点一下,谢谢。
用户手册中说,时钟寄存器配置之前需要先“解锁”,即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吗?