MSP430 Precision Timer Interrupt

This is a post similar to the previous one that described a timer interrupt with a M430G2452 mcu with the exception that we will be programming a M430G2553 mcu with a timer interrupt and the timer will be clocked using a high accuracy external oscillator.

The main difference between the M430G2553 and the M430G2452 is that the M430G2553 has two timer A’s and has a USCI communications module instead of the USI module in the M430G2452.

Both of these mcu’s directly support an external low frequency 32 kHz crystal. However, neither support the use of a high frequency crystal only. Instead, if higher accurracy is required, either mcu can be connected to an external 3.3 vdc crystal oscillator that has a CMOS or TTL compatable output.

Crystal Oscillator

Before working with timer A, review the section on interrupt vector addresses located in the data sheet and the timer A section in the user guide.

1.) Data sheet for the M430G2553 (TI document #SLAS735J).
2.) User guide for the M430G2553 (TI document #SLAU144).
3.) In Code Composer Studio open the header file (msp430g2553.h) for the M430G2553.


The M430G2553 contains a two 16 bit timers designated as Timer0_A3 and Timer1_A3 with the three indicating the number of combination capture /compare registers available. Here we will be using a single compare register. Both timers have four operating modes and also contain two timer interrupt vectors. We will be using Timer0 only.

M430G2553 Timer0 Interrupt Description

Two interrupt vectors are associated with the 16-bit Timer0_A3 module. Compare register TA0CCR0 is an interrupt vector for TA0CCR0 CCIFG, and TAIV is an interrupt vector for the remaining two CCIFG flags and TAIFG. In compare mode, any CCIFG flag is set if TAR counts to the associated TA0CCRx register value. The TAIFG flag is set when the timer (TAR) completes counting down to zero. Software is able to set or clear any CCIFG flag.

All CCIFG flags request an interrupt when their corresponding CCIE bit and the GIE bit are set. The TA0CCR1 CCIFG, TA0CCR2 CCIFG, and TAIFG flags are prioritized and combined to source a single interrupt vector. A program read of the interrupt vector register TAIV is used to determine which flag requested an interrupt. In the code example below, I used an “if” statement to assign interrupt #10 to the output. A “switch/case” statement can also be used.

In addition to controlling the timer delay using the value in the TA0CCR0 compare register, the IDx value in the TA0CTL register can also be changed to create other timer delays. Check the header file for more information.

Note 1: When using any interrupt, the code should be kept as short as possible. Calling a function inside an interrupt and the nesting of interrupts should be avoided if possible. Use an interrupt to check bit status or to update variables is best. Don’t forget to enable all maskable interrupts by setting the GIE bit in the status register.









end post




Leave a Reply

Your email address will not be published. Required fields are marked *