Attempts to lock the crystal more than once. Sometimes helps on startup fault.

This commit is contained in:
Travis Goodspeed 2019-09-01 20:48:59 -04:00
parent aea5c3d570
commit 61b53446bd

View File

@ -24,11 +24,18 @@ void ucs_slow(){
//! Initialize the XT1 crystal, and stabilize it.
void ucs_init(){
P5SEL |= BIT0 + BIT1; // Select XT1
UCSCTL6 |= XCAP_1; // Internal load cap
uint16_t i=0;
// Loop until XT1 & DCO stabilizes
do{
if(i++==0){
UCSCTL6 |= XT1DRIVE_3; // Higher drive strength.
P5SEL |= BIT0 + BIT1; // Select XT1
UCSCTL6 |= XCAP_1; // Internal load cap
}
UCSCTL7 &= ~(XT1LFOFFG + DCOFFG);
// Clear LFXT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags