Other Parts Discussed in Thread: MSP430FG4618
Hello,
I am playing with MSP430x26 MCu, currently i am trying to figure out the Basic timer + Timer_A. I am working on T.I code for the same family http://www.ti.com/lit/zip/slac151b. I have very basic and simple question and to find out the answer, i have read all the post regarding DCO, ACLk and MCLK but didnt get any clear idea. I need your suggestion on the step i have taken to set different registers, for example in all example code for timer or basic timer, the values for basic timer (DCO, MCLK, SMCLK and ACLK) are always assumed. For e.g in some files the DCO is default 1.45 MHz and there is no setting provided in main file and the register settings DCOCTL and BCSCTL1 are always set for maximum fdco(15,3). Same is the case for ACLK. I have tried to work out with to set DCO by
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
//DCO =1.45 MHz
BCSCTL1 |= RSEL0 +RSEL1 +RSEL2; (Rsel=7)
DCOCTL |= DCO0+DCO1; (DCO 3)
}
For ACLK i am working on an example code MSP430x261x_ta_05 where the led is toggeled on ACLK overflow and ACLK is source from TACLK or external crystal on xin and x out pin, the orginal code was as following, where i have palced breakpoint on interrupt module and the breakpoint was never execute. As i dont hav any external crystal.
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P4DIR |= 0x08; // P1.0 output
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 1000-1;
TACTL = TASSEL_1 + MC_1; // ACLK, upmode
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt
}
// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
P4OUT ^= 0x08; // Toggle P1.0
}
While reading the data sheet on page 289 its written
"ACLK is sourced from LFXT1CLK in LF mode with an internal load capacitance of 6pF". By following this i did a modification in code file oid main(void) _BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt // Timer A0 interrupt service routine Now i can see the breakpoint working, but i cant see my LED toggle. Kindly guide me what else i am missing? BR
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
//Enable a ACLK
BCSCTL1 |=XTS;
BCSCTL3 = LFXT1S0 + XCAP_1 ;
P4DIR |= 0x08; // P1.0 output
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 1000-1;
TACTL = TASSEL_1 + MC_1; // ACLK, upmode
}
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
P4OUT ^= 0x08; // Toggle P1.0
}