请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
当 CCS 工作区中的程序文件丢失其指向引用的头文件的所有链接时、这些头文件具有所有别名声明。
是否有办法修复此问题、以便链接再次正常工作? 例如、如果您在程序中右键单击任何别名寄存器值、例如"CS_clock_divider 2"、则不会发生任何情况。 通常情况下、CS_clock_divider@的声明会打开 cs.h 文件并突出显示"#define CS_clock_diver_2 CS_CTL1_divs_1"
我找到的唯一解决方法是打开一个新的工作区、并将相同的程序导入新的工作区。
/*******************************************************************************
* MSP432 Clock System - HFXT Startup
*
* Description: This is a simple code example that starts the 48MHz crystal
* attached to HFXTIN/HFXTOUT, sources MCLK from the crystal, and then
* blinks an LED using SysTick (which is sourced from MCLK). This is meant
* as a very elementary code example which shows the use how to start the
* high frequency crystal and source clock signals from HFXT.
*
* This program runs infinitely until manually halted by the user.
*
* MSP432P401
* ------------------
* /|\| |
* | | |
* --|RST P1.0 |---> P1.0 LED
* | PJ.3 HFXTIN |---------
* | | |
* | | < 48Mhz xTal >
* | | |
* | PJ.2 HFXTOUT |---------
*
******************************************************************************/
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
int period = 120; // Period of PWM
float Duty = 0.38f;
int main(void)
{
/* Halting the Watchdog */
MAP_WDT_A_holdTimer();
//![Simple CS Config]
/* Configuring pins for peripheral/crystal usage*/
MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ,
GPIO_PIN3 | GPIO_PIN2, GPIO_PRIMARY_MODULE_FUNCTION);
MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN2);
MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN2);
// initialize P2.6 and make them clock outputs
P2->DIR |= 0b10000000; // Set P2.7 as an Output pin
P2->SEL0 |= 0b10000000; // Set P2.7 as Primary function Timer_A0 CCR4 Output
P2->DIR |= 0b01000000; // Set P2.6 as an Output pin
P2->SEL0 |= 0b01000000; // Set P2.6 as Primary function Timer_A0 CCR3 Output
// let's set the clock frequency in the code.
CS_setExternalClockSourceFrequency(32000,48000000);
/* Starting HFXT in non-bypass mode without a timeout. Before we start
* we have to change VCORE to 1 to support the 48MHz frequency */
MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
MAP_FlashCtl_setWaitState(FLASH_BANK0, 1);
MAP_FlashCtl_setWaitState(FLASH_BANK1, 1);
CS_startHFXT(false);
/* Initializing MCLK, HSMCLK to HFXT (effectively 48MHz) SMCLK = 1/2 HSMCLK */
MAP_CS_initClockSignal(CS_MCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
MAP_CS_initClockSignal(CS_HSMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
MAP_CS_initClockSignal(CS_SMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_2);
//![Simple CS Config]
/* Configuring SysTick to trigger at 12000000 (MCLK is 48MHz so this will
* make it toggle every 0.25s) */
MAP_SysTick_enableModule();
MAP_SysTick_setPeriod(12000000);
MAP_Interrupt_enableSleepOnIsrExit();
MAP_SysTick_enableInterrupt();
/* Enabling MASTER interrupts */
MAP_Interrupt_enableMaster();