8
Apr 13

MSP430 Power Fet Booster Pack Basic IO code

This is just a quick post going over some basic IO functionality utilizing a booster pack I designed for the launch pad. I am toggling all of the IO pins of interest for my booster pack to make sure this new board I built up works correctly. I decided to post this because it is simple and easy to understand. There is also code for interrupt service routines that may help a few of you out.

Read the rest of this entry »

28
Dec 12

Single channel - Single Sequence ADC10 example

This is a quick write-up to show how to configure and use the MSP430's ADC10 in single channel/single sequence mode. Lets start off with the entire section of C-code and go from there:

/*
 * main.c
 *
 * Basic ADC10 Example
 * GetSomeSystems.com
 */

#include "msp430g2553.h"

// Globals variables
volatile int adc10_value;

void main(void) {

 	WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer

	// Configure Clock
	DCOCTL = CALDCO_8MHZ;	// MCLK = 8Mhz
	BCSCTL1 = CALBC1_8MHZ;
	// Configure Submain clock for TimerA
	BCSCTL2 &= ~SELM0;	// MCLK comes from DCO
	BCSCTL2 &= ~SELM1;
	BCSCTL2 &= ~SELS;	// Sub main clock comes from DCO
	BCSCTL2 |= DIVS0 + DIVS1;	// SMCLK = 1 MHz (DC0/8)


	// Setup ADC10
	ADC10CTL1 |= INCH_11 + ADC10SSEL_3 + CONSEQ_0  + ADC10DIV_0;
	ADC10CTL0 |= ADC10SHT_0 + ADC10IE + MSC + ADC10ON + SREF_0;

	ADC10CTL0 |= ENC + ADC10SC;	// start ADC10
	_BIS_SR(GIE + LPM0_bits);

}
/* *******************************
 * ADC10 ISR
 *	
 *	
 */
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{

	adc10_value = ADC10MEM;

// Maintanence
	ADC10CTL0 &=~ ADC10IFG;		// reset flag
	ADC10CTL0 |= ENC + ADC10SC;	// Begin new sampling sequence
}

Read the rest of this entry »

24
Dec 12

Interrupt driven Timer/Timing tutorial

This tutorial covers the basics of the TimerA0 capabilities including interrupt configuration. The Timer module counts clock cycles in an accumulation register called the "TAR" register. The chip I'm using (MSP430G2553) has 3x associated capture compare registers. These registers compare a set value (that they hold) to the TAR and throw an interrupt when they match. A simple way to look at this is that TimerA0 as 3x sub-modules (the capture compare registers) and all of them work together as a unit. Below is a screen shot from the datasheet.

TimerA0

Read the rest of this entry »