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.

Timer_A example code

Other Parts Discussed in Thread: MSP430AFE253

Hi guys,

I'm using MSP430AFE253 and trying to understand how to control Timer_A. I got couple questions about the example code:

1) in the file MSP430AFE_ta_01.c I don't really see the role of CCR0. I commented out the lines: CCR0 = 50000; in the main and CCR0 += 50000;  in the ISR and I still get the LED flashing with the same speed!  I thought in continous mode, The timer repeatedly counts from zero to 0FFFFh. So we can't change its period. Am I right?

2) In the file MSP430AFE_ta_03.c it is said that the Toggle rate is approximately ~17Hz. How was this value calculated?

3) In the file MSP430AFE_ta_04.c it is said that the Toggle rate is approximately ~0.2 Hz. How was this value calculated? With the command BCSCTL3 |= LFXT1S_2; VLOCLK is selected, and in the data sheet it is said that it is a low frequency oscillator with 12-kHz typical frequency. So how do we come down to 0.2Hz?

4) What is the difference between capture and comparison mode?

Thanks in advance!

  • MSP430-Beginner said:
    I thought in continous mode, The timer repeatedly counts from zero to 0FFFFh. So we can't change its period.

    Right. But you can still change the duty cycle. If th eother CCRx units run in a double-action mode, one action takes place at TAR==CCR0 and one at TAR==CCRx. So not writing something to CCR0 means one action happens at TAR=0 (=CCR0) and th eohter at TAR=CCRx, when you change CCR0 to 50000, the second action happens 50000 cycle slater (or 15536 earlier), affecting the observed duty cycle, but not the frequency.

    I don't know the source files, but...

    MSP430-Beginner said:
    VLOCLK is selected, and in the data sheet it is said that it is a low frequency oscillator with 12-kHz typical frequency. So how do we come down to 0.2Hz?

    12000/65536 = 0.183.

    MSP430-Beginner said:
    In the file MSP430AFE_ta_03.c it is said that the Toggle rate is approximately ~17Hz. How was this value calculated?

    I think the default DCO frequency is somewhere around 1.1MHz. 1100000/65536 = 16.78.

    Unfortunately these examples are not very 'telling' about why something works or how, only that it works exactly this way if it is programmed exactly this way.
    However, if you really understand the examples despite this fact, you have mastered the demonstrated module :)

**Attention** This is a public forum