专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
请问大家怎么将g2553的时钟设置成外接32.768k晶振的时钟
2019-03-24 08:34
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
TI MCU
5603
10
1784
才接触430g2553没多久,希望大家可以指导一下
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
10条回答
littleshrimp
2019-03-26 00:46
官方代码
//******************************************************************************
// MSP430G2xx3 Demo - LFXT1 Oscillator Fault Detection
//
// Description: System runs normally in LPM3 with WDT timer clocked by
// 32kHz ACLK with a 1x4 second interrupt. P1.0 is normally pulsed every
// second inside WDT interrupt. If an LFXT1 oscillator fault occurs,
// NMI is requested forcing exit from LPM3. P1.0 is toggled rapidly by software
// as long as LFXT1 oscillator fault is present. Assumed only LFXT1 as NMI
// source - code does not check for other NMI sources.
// ACLK = LFXT1 = 32768, MCLK = SMCLK = Default DCO
//
// //*External watch crystal on XIN XOUT is required for ACLK*//
//
//
// MSP430G2xx3
// ---------------
// /|| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// | P1.0|-->LED
//
// D. Dang
// Texas Instruments Inc.
// December 2010
// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include <msp430g2553.h>
volatile unsigned int i;
void main(void)
{
WDTCTL = WDT_ADLY_1000; // WDT 1s interval timer
IE1 |= WDTIE; // Enable WDT interrupt
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0; // All P1.x reset
P2DIR = 0xFF; // All P2.x outputs
P2OUT = 0; // All P2.x reset
// An immedate Osc Fault will occur next
IE1 |= OFIE; // Enable Osc Fault
while(1)
{
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/interrupt
}
}
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer (void)
{
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
}
#pragma vector=NMI_VECTOR
__interrupt void nmi_ (void)
{
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFFF; i > 0; i--); // Time for flag to set
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
}
while (IFG1 & OFIFG); // OSCFault flag still set?
IE1 |= OFIE; // Enable Osc Fault
}
复制代码
加载中...
查看其它10个回答
一周热门
更多
>
相关问题
相关文章
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
- //******************************************************************************
- // MSP430G2xx3 Demo - LFXT1 Oscillator Fault Detection
- //
- // Description: System runs normally in LPM3 with WDT timer clocked by
- // 32kHz ACLK with a 1x4 second interrupt. P1.0 is normally pulsed every
- // second inside WDT interrupt. If an LFXT1 oscillator fault occurs,
- // NMI is requested forcing exit from LPM3. P1.0 is toggled rapidly by software
- // as long as LFXT1 oscillator fault is present. Assumed only LFXT1 as NMI
- // source - code does not check for other NMI sources.
- // ACLK = LFXT1 = 32768, MCLK = SMCLK = Default DCO
- //
- // //*External watch crystal on XIN XOUT is required for ACLK*//
- //
- //
- // MSP430G2xx3
- // ---------------
- // /|| XIN|-
- // | | | 32kHz
- // --|RST XOUT|-
- // | |
- // | P1.0|-->LED
- //
- // D. Dang
- // Texas Instruments Inc.
- // December 2010
- // Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
- //******************************************************************************
- #include <msp430g2553.h>
- volatile unsigned int i;
- void main(void)
- {
- WDTCTL = WDT_ADLY_1000; // WDT 1s interval timer
- IE1 |= WDTIE; // Enable WDT interrupt
- P1DIR = 0xFF; // All P1.x outputs
- P1OUT = 0; // All P1.x reset
- P2DIR = 0xFF; // All P2.x outputs
- P2OUT = 0; // All P2.x reset
- // An immedate Osc Fault will occur next
- IE1 |= OFIE; // Enable Osc Fault
- while(1)
- {
- P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
- _BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/interrupt
- }
- }
- #pragma vector=WDT_VECTOR
- __interrupt void watchdog_timer (void)
- {
- _BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
- }
- #pragma vector=NMI_VECTOR
- __interrupt void nmi_ (void)
- {
- do
- {
- IFG1 &= ~OFIFG; // Clear OSCFault flag
- for (i = 0xFFF; i > 0; i--); // Time for flag to set
- P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
- }
- while (IFG1 & OFIFG); // OSCFault flag still set?
- IE1 |= OFIE; // Enable Osc Fault
- }
复制代码一周热门 更多>