主题中讨论的其他器件: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, ¶m ); //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, ¶m ); //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、请告诉我要在哪里更改。
谢谢你。