1475 views|0 replies

1140

Posts

0

Resources
The OP
 

Single chip microcomputer CPU card programming system main frequency setting [Copy link]

The calculation of data bit width depends on the main frequency of the MCU system. Under different main frequencies, it is necessary to write a data bit width calculation program according to the actual situation./******************************************** Function name: SystemClock2M Function function: Set the system main frequency to 2M Input parameters: None Output parameters: None Description: *******************************************/ void SystemClock2M(void) { unsigned int uiTranceiver,uiTemp=0; //XT1 is generated by the crystal oscillator, UCSCTL6 &= ~(XT1OFF); // Turn on XT1 UCSCTL6 |= XCAP_0; // Load capacitance uiTranceiver=TA0R; do { UCSCTL7 &= ~XT1LFOFFG; if(!(UCSCTL7&XT1LFOFFG)) { break; } if(TA0R>=uiTranceiver)uiTemp=TA0R; else uiTemp=TA0R+0x8000; }while((uiTemp-uiTranceiver)<(T200ms+T200ms+T200ms+T200ms)); __bis_SR_register(SCG0); // Disable FLL function, and enable FLL after the settings are completed UCSCTL0 = 0x0000; // UCSCTL1 = DCORSEL_4; // DCO = 2 MHz UCSCTL2 = FLLD_1 | 63; // __bic_SR_register(SCG0); // Re-enable FLL // Enable the FLL control loop __delay_cycles(250000); // Delay and wait for FLL to automatically adjust DCO, uiTemp=0; uiTranceiver=TA0R; do { UCSCTL7 &= ~(XT2OFFG | XT1LFOFFG | DCOFFG); SFRIFG1 &= ~OFIFG; if(!(SFRIFG1&OFIFG)) { break; } if(TA0R>=uiTranceiver)uiTemp=TA0R; else uiTemp=TA0R+0x8000; }while((uiTemp-uiTranceiver)<(T200ms+T200ms+T200ms+T200ms)); PMMCTL0_H = PMMPW_H; PMMCTL0_L=PMMCORE V_3; SVSMHCTL &= ~(SVMHE | SVSHE); SVSMLCTL &= ~(SVMLE | SVSLE); }

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list