⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msp430x54x_rtc_04.c

📁 MSP430F5系列TI官方源码
💻 C
字号:
//******************************************************************************
//  msp430FG5438 Demo - RTC in counter mode, Toggle P1.0 Inside ISR, DCO SMCLK
//
//  Description: Toggles P1.0 by xor'ing P1.0 inside of a RTC in counter mode ISR.
//  SMCLK provides the basic timer clock source. When using default DCO
//  register settings LED toggles every ~244us.
//  ACLK = REFO = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz	
//
//                msp430FG5438
//             -----------------
//         /|\|                 |
//          | |                 |
//          --|RST              |
//            |                 |
//            |             P1.0|-->LED
//
//  
//   M Smertneck
//   Texas Instruments Inc.
//   April 2008
//   Built with CCEv3.2 IAR Embedded Workbench Version: 3.42A
//******************************************************************************

#include <msp430x54x.h>

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P1DIR |= BIT0;                            // Set P1.0 as output
  RTCPS0CTL = RT0SSEL + RT0IP_6 + RT0PSIE;  // Set RTPS0 to /128 RT0PS clock
                                            // to SMCLK and enable RT0PS IE
  _BIS_SR(LPM0_bits + GIE);                 // Enter LPM0, enable interrupts
}


// RTC Interrupt Service Routine
#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR(void)
{
  P1OUT ^= 0x01;                            // Toggle P1.0
  RTCPS0CTL &= ~RT0PSIFG;
}

⌨️ 快捷键说明

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