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.

[参考译文] LP-MSP430FR2476:LP-MSP430FR2476_内部 时钟输出

Guru**** 1178510 points
Other Parts Discussed in Thread: MSP430FR2476, MSP-FET
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1350182/lp-msp430fr2476-lp-msp430fr2476_internal-clock-output

器件型号:LP-MSP430FR2476
主题中讨论的其他器件:MSP-FET、MSP430FR2476

我想使用示例代码"cs_ex1_D3852 1MHz Trim"监视 ACLK、SMCLK 和 MCLK 时钟。
没有时钟波形被输出到相应的引脚"P2.2"、"P1.7"和"P1.3"。

代码已按如下所示进行更改。

#include "driverlib.h"

//*****************************************************************************
//
//Target frequency for MCLK in kHz
//
//*****************************************************************************
#define CS_MCLK_DESIRED_FREQUENCY_IN_KHZ   1000

//*****************************************************************************
//
//MCLK/FLLRef Ratio
//
//*****************************************************************************
#define CS_MCLK_FLLREF_RATIO   30

//*****************************************************************************
//
//Variable to store current Clock values
//
//*****************************************************************************
uint32_t clockValue = 0;

#define GPIO_PORT_MCLK          GPIO_PORT_P1
#define GPIO_PIN_MCLK           GPIO_PIN3
#define GPIO_FUNCTION_MCLK      GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_SMCLK         GPIO_PORT_P1
#define GPIO_PIN_SMCLK          GPIO_PIN7
#define GPIO_FUNCTION_SMCLK     GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_ACLK          GPIO_PORT_P2
#define GPIO_PIN_ACLK           GPIO_PIN2
#define GPIO_FUNCTION_ACLK      GPIO_PRIMARY_MODULE_FUNCTION

//*****************************************************************************
//
//Variable to store status of Oscillator fault flags
//
//*****************************************************************************
uint16_t status;

void main (void)
{
    //Stop watchdog timer
    WDT_A_hold(WDT_A_BASE);

    GPIO_setAsOutputPin(
            GPIO_PORT_P5,
            GPIO_PIN0
            );

    //ACLK set out to pins
    GPIO_setAsPeripheralModuleFunctionOutputPin(
        GPIO_PORT_ACLK,
        GPIO_PIN_ACLK,
        GPIO_FUNCTION_ACLK
        );
    //SMCLK set out to pins
    GPIO_setAsPeripheralModuleFunctionOutputPin(
        GPIO_PORT_SMCLK,
        GPIO_PIN_SMCLK,
        GPIO_FUNCTION_SMCLK
        );
    //MCLK set out to pins
    GPIO_setAsPeripheralModuleFunctionOutputPin(
        GPIO_PORT_MCLK,
        GPIO_PIN_MCLK,
        GPIO_FUNCTION_MCLK
        );

    /*
     * Disable the GPIO power-on default high-impedance mode to activate
     * previously configured port settings
     */
    PMM_unlockLPM5();

    //Set DCO FLL reference = REFO
    CS_initClockSignal(
        CS_FLLREF,
        CS_REFOCLK_SELECT,
        CS_CLOCK_DIVIDER_1
        );

    //Set ACLK = REFO
    CS_initClockSignal(
        CS_ACLK,
        CS_REFOCLK_SELECT,
        CS_CLOCK_DIVIDER_1
        );
    
    //Create struct variable to store proper software trim values
    CS_initFLLParam param = {0};
    
    //Set Ratio/Desired MCLK Frequency, initialize DCO, save trim values
    CS_initFLLCalculateTrim(
        CS_MCLK_DESIRED_FREQUENCY_IN_KHZ,
        CS_MCLK_FLLREF_RATIO,
        &param
        );

    //Clear all OSC fault flag
    CS_clearAllOscFlagsWithTimeout(1000);

    //For demonstration purpose, change DCO clock freq to 16MHz
    CS_initFLLSettle(
        16000,
        487
        );

    //Clear all OSC fault flag
    CS_clearAllOscFlagsWithTimeout(1000);

    //Reload DCO trim values that were calculated earlier
    CS_initFLLLoadTrim(
        CS_MCLK_DESIRED_FREQUENCY_IN_KHZ,
        CS_MCLK_FLLREF_RATIO,
        &param
        );

    //Clear all OSC fault flag
    CS_clearAllOscFlagsWithTimeout(1000);

    //Enable oscillator fault interrupt
    SFR_enableInterrupt(SFR_OSCILLATOR_FAULT_INTERRUPT);

    // Enable global interrupt
    __bis_SR_register(GIE);

    //Verify if the Clock settings are as expected
    clockValue = CS_getSMCLK();
    clockValue = CS_getMCLK();
    clockValue = CS_getACLK();

    while (1)
    {
        GPIO_toggleOutputOnPin(
                GPIO_PORT_P5,
                    GPIO_PIN3
                    );

                //Delay
                __delay_cycles(1000000);
    }
}


#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=UNMI_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(UNMI_VECTOR)))
#endif
void NMI_ISR(void)
{
  do {
    // If it still can't clear the oscillator fault flags after the timeout,
    // trap and wait here.
    status = CS_clearAllOscFlagsWithTimeout(1000);
  } while(status != 0);
}

我如何输出内部时钟?
另外、如果我要将内部时钟更改为4MHz、请告诉我要在哪里更改。
谢谢你。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    > #define GPIO_function_MCLK GPIO_primary_module_function

    > #define GPIO_FUNCTION_SMCLK GPIO_PRIMARY_MODULE_FUNCTION

    > #define GPIO_FUNCTION_ACLK GPIO_PRIMARY_MODULE_FUNCTION

    数据表(SLASEO7C)表9-23/-24指示这些器件上的 PSEL 为10、因此、这些器件(所有)应使用  GPIO_secondary_module_function

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢你。

    可以正常工作、但当我在 Debug 中点击"Resume"时、操作变得不稳定、我无法正确获取 MCLK 输出、并出现错误"Power Failure on Target CPU"。
    此外、MSP-FET 的"模式"不停地运行。
    当我单击"终止"并重新打开电源时、我能够获得 MCLK 输出。
    电源从外部连接。
    问题出在哪呢?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您是否尝试过 TI 的一些演示代码、  

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2018, 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,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //  MSP430FR267x Demo - Toggle P1.0 using software
    //
    //  Description: Toggle P1.0 every 0.05s using software.
    //  By default, FR267x select XT1 as FLL reference.
    //  If XT1 is present, the PxSEL(XIN & XOUT) needs to configure.
    //  If XT1 is absent, switch to select REFO as FLL reference automatically.
    //  XT1 is considered to be absent in this example.
    //  ACLK = default REFO ~32768Hz, MCLK = SMCLK = default DCODIV ~1MHz.
    //
    //           MSP430FR2676
    //         ---------------
    //     /|\|               |
    //      | |               |
    //      --|RST            |
    //        |           P1.0|-->LED
    //
    //   Longyu Fang
    //   Texas Instruments Inc.
    //   August 2018
    //   Built with IAR Embedded Workbench v7.12.1 & Code Composer Studio v8.1.0
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    
        P1OUT &= ~BIT0;                         // Clear P1.0 output latch for a defined power-on state
        P1DIR |= BIT0;                          // Set P1.0 to output direction
    
        PM5CTL0 &= ~LOCKLPM5;                   // Disable the GPIO power-on default high-impedance mode
                                                // to activate previously configured port settings
    
        while(1)
        {
            P1OUT ^= BIT0;                      // Toggle P1.0 using exclusive-OR
            __delay_cycles(50000);             // Delay for 50000*(1/MCLK)=0.05s
        }
    }
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我在 Launchpad 原理图中看不到与这些引脚的任何明显冲突。 除了示波器外、您是否有任何器件连接到这些引脚?

    此外、如何将 MSP-FET 连接到 Launchpad? (我始终使用板载 eZ-FET。)

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我在板上安装了 MSP430FR2476、而不是 Launchpad 并确认了其运行。
    除示波器外、没有任何器件连接到引脚"P2.2"、"P1.7"和"P1.3"。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我在 Launchpad 上运行该代码时、不会看到您的症状。

    您如何为电路板供电? 您是否已在 DVCC/DVSS 上包含旁路电容器? [参考数据表(SLASEO7C)第10.1.1节]

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    根据数据表安装电容器。
    电源从外部提供给微控制器和 MSP-FET。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    如果使用外部(例如台式)电源、请确保使用 J1 (" VCC 目标")而非 J2 (" VCC 工具")连接 MSP-FET。 [请参考硬件工具 UG (SLAU278AH)图2-3 ]如果使用 J2、两个电源之间将发生冲突。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    它已连接到" VCC 目标"。
    (另外、如果关闭外部电源、将无法再与微控制器进行通信、因此这可能是正确的。)

    当频率输出被置位时(在 GPIO_PRIMARY_MODULE_FUNCTION 中定义为"P2.2"、"P1.7"或"P1.3")、就会发生这种现象。
    当频率输出没被设定时、你可以毫无问题地进行调试、而操作也没有问题。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您可以尝试使用这个演示代码、看看它是否起作用

    e2e.ti.com/.../clock_5F00_output.c

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我在使用主要或次要版本的 Launchpad 上没有看到此症状(但您仍然需要辅助版本)。 我没有 MSP-FET、所以这里可能有些东西。

    这会重复发生吗? 断开示波器探头是否有区别?