This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR6972: 关于软件清LFXTOFFG,单片机重启问题

Part Number: MSP430FR6972

软件清LFXTOFFG时,会导致单片机重启,我在用户手册上没有找到相关解释,是正常现象吗?如果是正常现象,能否避免软件清LFXTOFFG时,单片机重启呢?

  • 软件清LFXTOFFG时

    请问您是如何清的呢?能否给出相关代码?

    另外您为何需要清除LFXTOFFG?

  • CSCTL5 &= ~(LFXTOFFG);

    外部32768晶振遇到在设备组装时可能会受到轻微挤压导致,32768晶振瞬间故障,但是挤压过后又会恢复震荡,因为我的ACLK用的是外部的32768,单片机用户手册说,当外部晶振故障时会自动置位LFXTOFFG,并且自动切换到MODCLK代替32768供给ACLK,LFXTOFFG需要软件清除才会从MODCLK切回到32768。但是一执行CSCTL5 &= ~(LFXTOFFG);语句后单片机就自动重启一次。后来实验发现就算LFXTOFFG没置位,执行CSCTL5 &= ~(LFXTOFFG);也会重启一次。

  • 时钟系统似乎工作不正常。您能否将 MCLK 和 SMCLK 输出到 GPIO 并确定频率范围?

  • CSCTL0_H = CSKEY >> 8;
    CSCTL1 = DCOFSEL_1;
    CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
    CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;
    CSCTL4 = 0;
    CSCTL4 |= VLOOFF + SMCLKOFF + HFXTOFF;
    do
    {
    CSCTL5 &= ~(LFXTOFFG+ HFXTOFFG);//
    SFRIFG1 &= ~OFIFG;
    }while (SFRIFG1&OFIFG);
    CSCTL5 &= ~(ENSTFCNT1 + ENSTFCNT2);
    CSCTL6 &=~( ACLKREQEN|MCLKREQEN|SMCLKREQEN);
    CSCTL0_H = 0;

    这是我的时钟配置,MCLK是用的DCOCLK,您要我在什么情况下,是把LFXTCLK输出吗?

  • 是把LFXTCLK输出吗?

    是的,您的理解是正确的。

  • 正常运行时32.75K--32.81K

    晶振受挤压后自动跳到modclk时是36.98K--37.0K

  • 谢谢您的反馈。

    请您试一下下面的代码能否正常运行,而不会复位

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /* --COPYRIGHT--,BSD_EX
    * Copyright (c) 2014, 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,
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • 能够正常运行不重启,下图是P1.0波形

  • 上午又做实验应该是找到原因了

    我的时钟初始化代码中

    第一条语句解锁,然后最后一条又相当于锁了时钟的寄存器,手册里边说的是,

    CSKEY password. Must always be written with A5h; a PUC is generated if any
    other value is written. Always reads as 96h. After the correct password is written,
    all CS registers are available for writing.

    相当于我再后边的程序没有解锁,直接这样写CSCTL5 &= ~(LFXTOFFG);,导致了一个PUC,所以只要执行这个就复位。

    后来改了一下清LFXTOFFG的后边程序的代码

    CSCTL0_H = CSKEY >> 8;
    do
    {
    CSCTL5 &= ~(LFXTOFFG+ HFXTOFFG);//
    SFRIFG1 &= ~OFIFG;
    }while (SFRIFG1&OFIFG);
    CSCTL0_H = 0;

    这样就OK了,不重启

    再次感谢您抽时间给我解答问题,没有您的帮助我还不知道啥时候能找出问题所在,谢谢!!!!!

  • 谢谢您的分享!很高兴您能解决问题