Other Parts Discussed in Thread: MSP430F5529
Hello!
I am a little new to the MSP430 family and I thought this community was pretty helpful so far, so here's my question! I am using an MSP430F5529 Launchpad for this project.
My project deals with taking in an analog velocity signal (0-3.3 V) and creating a pulse for every foot that was traveled according to the velocity. Right now, I need the digital output pulse to have a maximum toggle frequency of at least 50 kHz, higher is fine. I am trying to set up a timer-based ISR which calls at a much higher frequency by having the timer based on the SMCLK which in turn should be controlled by the DCO, which I wanted to set to about 8MHz. So far, I have been unable to call the ISR faster than the normal ~32 kHz frequency which leads me to believe that configuring the timer for a higher frequency was not successful. This is what I have attempted through browsing the sample codes available on this topic:
/*THE NEXT SECTION SETS DCO TO ~8MHz, CONTROLS THE SMCLK*/
UCSCTL3 = SELREF_2; // Set DCO FLL reference = REFO
UCSCTL4 |= SELA_2; // Set ACLK = REFO
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
// Loop until XT1,XT2 & DCO stabilizes - In this case only DCO has to stabilize
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
__bis_SR_register(SCG0); // Disable the FLL control loop
UCSCTL1 = DCORSEL_5; // Select DCO range 16MHz operation
UCSCTL2 |= 249; // Set DCO Multiplier for 8MHz
// (N + 1) * FLLRef = Fdco
// (249 + 1) * 32768 = 8MHz
__bic_SR_register(SCG0); // Enable the FLL control loop
// Worst-case settling time for the DCO when the DCO range bits have been
// changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
// UG for optimization.
// 32 x 32 x 8 MHz / 32,768 Hz = 250000 = MCLK cycles for DCO to settle
__delay_cycles(250000);
//Timer Setup
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CTL = TASSEL_2 + MC_2 + TACLR + ID_3; // SMCLK, continuous, clear TAR, /8
// Timer1 A0 interrupt service routine
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
P4OUT ^= BIT7;
}
I have the SMCLK divided by 8 solely so I can tell that the LED on P4.7 is toggling at a slower frequency or higher frequency based on if I configured the clock to work or not. Eventually, I want the ISR to be called at least at 50 kHz or higher, but I can't seem to configure the clocks correctly. Any help/advice you can lend me will be greatly appreciated!
Thanks,
Thomas