CPU card programming system main frequency setting[Copy link]
This post was last edited by Aguilera on 2019-3-16 21:19 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)[/ color] { unsigned int uiTranceiver,uiTemp=0; //XT1 is generated by the crystal oscillator, [color=# 000000]UCSCTL6 &= ~(XT1OFF); // Turn on XT1 UCSCTL6 |= /color] { UCSCTL7 &= ~XT1LFOFFG; if(!(UCSCTL7&XT1LFOFFG)) { break; } if(TA0R>=uiTranceiver)uiTemp=TA0R; else ui Temp=TA0R+0x8000; }while((uiTemp-uiTranceiver)<(T200ms+T200ms+T200ms+T200ms)); __bis_SR_register(SCG0); // Disable the FLL function, and then enable the FLL after the settings are completed UCSCTL0 = 0x0000; // UCSCTL1 = DCORSEL_4; // DCO = 2 MHz UCSCTL2 = FLLD_1 | 63; // __bic_SR_register(SCG0); // Re-enable the FLL // Enable the FLL control loop __delay_cycles(250000); // Delay and wait for the FLL to automatically adjust the DCO, uiTemp=0; uiTranceiver=TA0R; do { [ backcolor=white]UCSCTL7 &= ~(XT2OFFG |(SFRIFG1&OFIFG)) { break;[ /backcolor] } if(TA0R>=uiTranceiver)uiTemp=TA0R;[ /backcolor] else uiTemp=TA0R+0x8000; }while((uiTemp-uiTranceiver)<(T200ms+T200ms+T200ms+T200ms)); PMMCTL0_H = PMMPW_H; PMMCTL0_L=PMMCOREV_3; SVSMHCTL &= ~ (SVMHE | SVSHE); SVSMLCTL &= ~(SVMLE | SVSLE); }