fet140_ta11.c

来自「430单片机的基本例程。都已经调通可以使用。是新手上路必备」· C语言 代码 · 共 41 行

C
41
字号
//******************************************************************************
//  MSP-FET430P140 Demo - Timer_A Toggle P1.1 With TA0 upmode, 32kHz ACLK  
//
//  Description; Toggle P1.1 using hardware TA0 output. Timer_A is configured
//  in upmode with CCR0 defining period, TA0 also output on P1.1. In this 
//  example, CCR0 is loaded with 10-1 and TA0 will toggle P1.1 at TACLK/10.
//  Thus the ouput frequency on P1.1 will be the TACLK/20.  No CPU or software
//  resources required. Normal mode is LPM3.
//  ACLK = TACLK = 32kHz, MCLK = default DCO ~ 800kHz
//  As coded with TACLK = ACLK, P1.1 output frequency = 32768/20 = 1.6384kHz
//   
//           MSP430F149
//         -----------------
//     /|\|              XIN|-  
//      | |                 | 32kHz
//      --|RST          XOUT|-
//        |                 |
//        |             P1.1|-->TA0 ACLK/20
//
//  M.Buccini
//  Texas Instruments, Inc
//  September 2003
//  Built with IAR Embedded Workbench Version: 1.26B
//  January 2004
//  Updated for IAR Embedded Workbench Version: 2.21B
//******************************************************************************

#include <msp430x14x.h>

void main(void)
{ 
  WDTCTL = WDTPW + WDTHOLD;             // Stop WDT
  P1DIR |= 0x02;                        // P1.1 output
  P1SEL |= 0x02;                        // P1.1 option select
  CCTL0 = OUTMOD_4;                     // CCR0 toggle mode
  CCR0 = 10-1;
  TACTL = TASSEL_1 + MC_1;              // ACLK, upmode
 
  _BIS_SR(LPM3_bits);                   // Enter LPM3 w/interrupt
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?