msp430G2553时钟选择与分频程序
2014-12-17 来源:51hei
msp430G2553单片机的时钟选择和分频程序如下:
#include "msp430G2553.h"
#define unchar unsigned char
#define uint unsigned int
uint Fre;
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
BCSCTL2 |=SELM_1+DIVM_0;
P1DIR &=~BIT3;
P1REN |=BIT3;
P1OUT |=BIT3;
P1DIR |=BIT0;
P1IE |=BIT3;
P1IES &=~BIT3;
_EINT();
while(1)
{
P1OUT ^=BIT0;
__delay_cycles(1000000);
}
}
#pragma vector=PORT1_VECTOR
__interrupt void PORTP13(void)
{
uint temp,pushkey=0;
pushkey=BIT3 & (~P1DIR);
__delay_cycles(100000);
temp=P1IN;
if((~temp) & BIT3==pushkey)
{
Fre++;
if(Fre>3) Fre=0;
switch(Fre)
{
case 0: DCOCTL=CALDCO_1MHZ;BCSCTL1 = CALBC1_1MHZ;break;
case 1: DCOCTL=CALDCO_8MHZ;BCSCTL1 = CALBC1_8MHZ;break;
case 2: DCOCTL=CALDCO_12MHZ;BCSCTL1 = CALBC1_12MHZ;break;
case 3: DCOCTL=CALDCO_16MHZ;BCSCTL1 = CALBC1_16MHZ;break;
default:break;
}
}
P1IFG &=~BIT3;
}
上一篇:MSP430单片机串口通信详解
下一篇:MSP430时钟设置程序
- msp430g2553+pcf8574+dht11+lcd1602
- 基于MSP430G2553的模拟风扇控制系统
- MSP430G2553 PWM控制速度,并自我检测和简单调节速度
- 利用MSP430G2553测量信号幅度
- 利用MSP430G2553测量信号频率(频率计)
- 基于MSP430G2553和MATLAB Appdesigner的心电信号复现和心率显示
- MSP430G2553 频率、占空比、脉冲宽度测量
- MSP430G2553 移植 Contiki RTOS 实时操作系统
- 【MSP430G2553】图形化开发笔记(1) 配置环境
- 【MSP430G2553】图形化开发笔记(2) 系统时钟和低功耗模式