Archive for Code Examples

MSP430 Timer Interrupt Example

MSP430G2553 TIMER INTERRUPT EXAMPLE

This example shows how the timer interrupts can be used to generate precision square waves.

Two interrupt vectors are associated with the 16-bit Timer_A module.

The TACCR0 CCIFG flag has the highest Timer_A interrupt priority and has a dedicated interrupt vector.

The TACCR1 CCIFG, TACCR2 CCIFG, and TAIFG flags are prioritized and combined to source a single interrupt vector. The interrupt vector register TAIV is used to determine which flag requested an interrupt.

Note: An external 4 MHz oscillator was used to clock the M430G2553.

 

TIMER 0 INTERRUPT OUTPUTS

 

TIMER 1 INTERRUPT OUTPUTS

 

END POST

MSP430 Encoder State Machine

This is a basic encoder state machine that can be used with the Texas Instruments EXP430G2553 Launchpad.

The program toggles LED2 (grn) when the encoder is rotated clockwise and toggles LED1 (red) when the encoder is rotated counterclockwise.

Additional code can be added to increment or decrement a timer register or other variable using an encoder. The code would be added where the if – else statements are located within the switch – case statement.

Example Here: http://saroselectronics.com/msp430-encoder-adjustable-pwm/

 

end post

 

 

MSP430 External Oscillator Code

CODE EXAMPLE TO CONFIGURE A MSP430G2553 FOR AN EXTERNAL OSCILLLATOR.