Hello-
We are using the msp430f5419a and would like to run our RTC off the external crystal. Do you have any example code you could share?
Here’s the clock test code we made. We now know that it is not using the crystal as we grabbed an MSP-TS430PZ5x100 and that doesn’t have a crystal by default and the code below still works! So we’re a little bit stumped as we think we’re telling it to use the external crystal.
Built with Energia, an MSP430 variant of Arduino. We modeled the code after msp430x54x_ta3_05.c from the slac166s download from TI for examples.
volatile unsigned int counter = 0;
volatile int tick = LOW;
unsigned long startTime;
float percentOff;
boolean pin = LOW;
void setup()
{
//Serial.begin(9600);
pinMode(MPU_LED, OUTPUT);
digitalWrite(MPU_LED, pin);
pinMode(DEBUG_UARTRXD, OUTPUT);
digitalWrite(DEBUG_UARTRXD, LOW);
pinMode(17, OUTPUT);
digitalWrite(17, LOW);
delay(1000);
//Serial.println("Started");
//Serial.println(UCSCTL4);
//Serial.println(UCSCTL4, HEX);
//Serial.println(UCSCTL4, BIN);
// SELA(XT1CLK) | resv | SELS(DCOCLK) | resv | SELM(DCOCLK)
UCSCTL4 = 0 << 8 | 0 < 7 | 3 < 4 | 0 < 3 | 3; //We want 51 = 00000110011; //We saw 1000110011
// XT1DRIVE | XTS | XT1BYPASS | XCAP | SMCLKOFF | XT1OFF
UCSCTL6 = 0 << 6 | 0 << 5 | 0 << 4 | 3 << 2 | 0 << 1 | 0; //We want 000000011100000
//Serial.println(UCSCTL4);
//Serial.println(UCSCTL4, HEX);
//Serial.println(UCSCTL4, BIN);
counter = 0;
startTime = millis();
ConfigTimerB(); //Configure the timer
}
void loop()
{
}
/*****************************************************************
*
* FUNCTION: configTimerA
*
* PURPOSE: Configure the TimerA
*
* PARAMETERS: delayCycles: number of clock cycles to delay
*
*****************************************************************/
void ConfigTimerB()
{
TB0CCTL0 = CCIE; // TACCR0 interrupt enabled
TB0CCR0 = 1000 - 1;
TB0CTL = TBSSEL_1 + MC_1 + TBCLR;
}
/*****************************************************************
*
* FUNCTION: Timer_A0
*
* PURPOSE: Interrupt Handler to service the TimerA0 interrupt
*
* PARAMETERS: none
*
*****************************************************************/
#pragma vector=TIMER0_B0_VECTOR
__interrupt void Timer_B0(void)
{
digitalWrite(17, !digitalRead(17));
}
Thanks and Best Regards,
Tim Starr on behalf of DA@MI