TI官方的提供的代码
/* --COPYRIGHT--,BSD_EX
* Copyright (c) 2012, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*******************************************************************************
*
* MSP430 CODE EXAMPLE DISCLAIMER
*
* MSP430 code examples are self-contained low-level programs that typically
* demonstrate a single peripheral function or device feature in a highly
* concise manner. For this the code may rely on the device's power-on default
* register values and settings such as the clock configuration and care must
* be taken when combining code from several examples to avoid potential side
* effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
* for an API functional library-approach to peripheral configuration.
*
* --/COPYRIGHT--*/
//******************************************************************************
// MSP-FET430P140 Demo - Basic Clock, Output Buffered SMCLK, ACLK and MCLK
//
// Description: Output buffered MCLK, SMCLK and ACLK.
// ACLK = LFXT1 = 32768, MCLK = DCO Max, SMCLK = XT2
// //* XTAL's REQUIRED - NOT INSTALLED ON FET *//
// //* Min Vcc required varies with MCLK frequency - refer to datasheet *//
//
// MSP430F149
// -----------------
// /|| XIN|-
// | | | 32k
// --|RST XOUT|-
// | |
// | XT2IN|-
// | | XTAL (455k - 8Mhz)
// |RST XT2OUT|-
// | |
// | P5.4|-->MCLK = DCO Max
// | P5.5|-->SMCLK = XT2
// | P5.6|-->ACLK = 32kHz
//
// M. Buccini
// Texas Instruments Inc.
// Feb 2005
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A
//******************************************************************************
#include
MCLK由XT2CLK或者DCOCLK或者LFXT1CLK提供;主要设置SELMx;
SMCLK由XT2CLK或者DCOCLK提供;主要设置SELS;
寄存器说明
配置好时钟主要看懂以下5个寄存器就好,算是比较容易了,刚开始比较麻烦,后来看了带锁频器的F5438A有9个寄存器来控制时钟系统,突然觉得这个还是可以接受的,哭脸一个.
上面的注意有一个复位是用POR不是PUC;
DCOCTL是调制DCOCLK时钟源的频率的(所以说,这个是个可调频率的振荡器,不是市面上卖的那种,是多少就是多少那种);对定时要求不是特别严格的,可以直接用默认的就好;
DCOx主调
MODx微调
1&2就是开始做选择了,时钟的分频呀啥啥啥的,哎,其实还好,比5.1稍稍麻烦一点点而已
两个中断相关寄存器。中断使能位和中断标志位。
两个寄存器目前用到了这两位,就先写出这两位,其他位其实是有东西的
关键字:MSP430F149 基本时钟『本文转载自网络,版权归原作者所有,如有侵权请联系删除』