This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I tested the launchpad board with internal DCO and all works ok.
Then I soldered an external 16 Mhz crystal with 18pf capacitors. I'm trying to run this code to test (with an oscilloscope) if the HFTX. There is some problem because my system produce an clock event every 13ms instead of 62.5ms. The strange thing is that if I remove the crystal the system still working with the same clock period.
Someone have some example with the MSP430FR59xx family ?
Thanks
This is my code: I'm not sure about PJ configuration
#include <msp430.h>
int main(void)
{
//SET PORT
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode to activate previously configured port settings
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog time
//SET LED PORT
P1SEL0=0b00000000;
P1SEL1=0b00000000;
P1OUT = 0;
P1DIR = 0xFF;
//SET HFXT PORT : not sure
PJDIR = 0x00;
PJSEL0|=BIT7|BIT6;
PJSEL1=0x00;
//SET CLOCK SURCE
CSCTL0_H = 0xA5; // Unlock CS registers
CSCTL1_L=0b00000000; //DCO 1Mhz (not used)
CSCTL2_L=SELS__HFXTCLK | SELM__HFXTCLK; //SMCLK and MCLK source = HFXT
CSCTL3_L=DIVS__1; //SMCLK/1 and MCLK/1
CSCTL4_H = HFXTDRIVE1_H|HFFREQ1_H; //Ser current crystal and frequence = 16Mhz
//SET CLOCK
TA0CCTL0 = CCIE; // TACCR0 interrupt enabled
TA0CCR0 = 62500; // Value to compare with the timer to generate interrupt
TA0CTL = TASSEL__SMCLK |ID__1| MC__UP; // select SMCLK, Divide SMCLK/1, UP mode
TA0EX0 = TAIDEX_0; // DIV1 : So timer_CLK = SMCLK/1
__bis_SR_register(LPM1_bits + GIE); // Enter LPM0 plus ENABLE INTERRUPT
while(1)
{
}
return 0;
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer0_A0_ISR (void)
{
P1OUT^=BIT0; //Toggle led P1.0
}
The code examples for your chip show how it's done correctly.
Or you could simply use driverlib.
Hello user 4451984,
you have to clear the pending oscillator fault flags after you initialized the HFXT. You can use the following code to do this.
do { // Check for fault flags
CSCTL5 &= ~(HFXTOFFG + LFXTOFFG);
} while (CSCTL5 & (HFXTOFFG + LFXTOFFG));
do { // Check for general OSC fault
SFRIFG1 &= ~(OFIFG);
} while (SFRIFG1 & OFIFG);
After the flag are clear the fault-logic of the clock system will route the clock sources (LFXT or HFXT) to your selected clock paths (MCLK, SMCLK, ACLK).
If the HFXT does not start you can try to increase the biasing of the HFXT with a higher HFXTDRIVE- setting.
There is one thing more what you have to consider, when you want use MCLK with 16 MHz you have to enable the wait states for FRAM access. You can use copy the following code line at the beginning of your main-loop:
FRCTL0 = FWPW+NACCESS_1;
Best regards,
Michael
**Attention** This is a public forum