Archive for Code Examples

MSP430 LED Voltage Display Code

M430G2553 code to create a DC voltmeter with a three digit multiplexed LED display. The voltage range is dependent on the input voltage divider.

MAIN FUNCTION CODE  

INTERRUPT AND DELAY FUNCTION

VOLTAGE DISPLAY SCHEMATIC

End Post

MSP430 OLED Display Code

Program examples for the the Newhaven NHD-0216KZW-AG5 OLED display.

FUNCTION TO INITIALIZE OLED DISPLAY

FUNCTION TO SEND A SINGLE ASCII CHARACTER

FUNCTION TO SEND A CHARACTER STRING

FUNCTION TO CREATE A 10 BIT BIT-BANGED SPI

 

The entire program code for the PWM display will be published in a separate post.

End Post

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.