MSP430F169
The MSP430F169 is a 16-bit microcontroller with 60KB of flash memory and 2KB of RAM. It also features a wide variety of relatively easy to use onbaord peripherals including:
- 12-Bit analog to digital converter (ADC)
- 12-Bit digital to analog converter (DAC)
- Voltage comparator
- Two 16-Bit timer counters with PWM capability
- Three-channel direct memory access (DMA) controller
- UART/I2C/SPI interface controller
There are a number of free programming environments available for the MSP430 family including IAR Kickstart, TI Code Composer, and MSPGCC. Both IAR and Code Composer impose limitations on compiled code and data size. We will be using the IAR Kickstart environment for its compatibility with the Olimex parallel port JTAG programmer and easy visual debugging tools.
Development board
The development board provided is the Olimex MSP430P169. Note that all of the pins on the breakout header are labelled in the format Px.x; for example, P1.5 refers to the MSP's GPIO pin 5 on port 1. Also, both edges of the prototype area are connected to either +3.3V or GND along their entire length.
You will need to modify the development boards by adding an 8 MHz crystal to the boards. This crystal is included in your parts kit. C32 and C33 (both 12 pF) are also required for this modification.
A parallel port JTAG programmer is provided for communication between the laboratory PC and the development board.
Interfacing with the MSP430
Be cautious hooking up the MSP430 to your circuit. The I/O pins can source only a limited amount of current, about 6mA per pin with a maximum current of about 48mA for all pins combined. Exceeding these maximum values will destroy an IO port. To prevent this it is suggested that you buffer the PWM lines with a transistor or gate drive such as the TC427 which requires neglible switching current.
Control of the analog and digital inputs and outputs of the MSP430 is described in Tutorial 1 and Tutorial 2. Tutorial 2 includes project files (Update 2/22/08) that set up the I/O ports needed to run Experiment 5. The variables used below are defined in the file main.c of the project files, and you can insert your code into main.c as well. Similar project files for Experiment 4 are included here.
- Analog-to-digital converter
- There are eight (multiplexed) A/D channels, labeled A0 through A7 in the pinout diagram. Some of these pins are shared with other functions.
- A/D channels A6 and A7 will not be used because their pins are used for D/A outputs instead.
- A/D channels A0 and A1 will not be used because the development board hard-wires their pins to the LED and button instead.
- A/D channels A2 through A5 are available as usable A/D inputs.
- A/D channel A2 is connected to the connector pin labeled P6.2. In the project files, the sampled voltage appears in the variable Adc_data[0].
- A/D channels A3, A4, and A5 are connected to connector pins P6.3, P6.4, and P6.5 respectively. In the project files, the sampled voltages of these pins appear in the variables Adc_Data[1], Adc_Data[2], and Adc_Data[3].
- These inputs convert voltages in the range 0 to 2.5 V. Do not apply voltages exceeding 3.3 V or negative voltages to these pins!
- Digital-to-analog converter
- There are two D/A converter channels: DAC0 and DAC1.
- Channel DAC0 is connected to pin P6.6 of the connector. In the project files, the voltage at this pin is controlled by writing to the DAC0 data register DAC12_0DAT.
- Channel DAC1 is connected to pin P6.7 of the connector. In the project files, the voltage at this pin is controlled by writing to the DAC1 data register DAC12_1DAT.
- See the PWM tutorial for additional information on using the DAC.
- Timer / PWM (Updated 2/22/08)
- Timer B is used to generate pulse-width modulated waveforms.
- In the project files, Timer B output TB2 is used to output a PWM waveform which appears on pin P4.2. The duty cycle of this waveform is controlled by writing to the global variable D0.
- In the project files, Timer B output TA3 is used to output a PWM waveform which appears on pin P4.3. The duty cycle of this waveform is controlled by writing to the global variable D1.
- See the PWM tutorial for additional information on using the timer as a pulse-width modulator.
- The project files were updated on 2/22/08 to reflect the above changes, fixing a bug that occured when the timer A duty cycle was set to zero. You can download the new project files, paste your existing code into the main.c file, and move your PWM output connections to pins P4.2 and P4.3, and your code should work.
- LED and button
- There is a small LED on the development board, which is connected to pin P6.0. The LED can be controlled by writing to bit 0 of peripheral 6, as illustrated in the LED tutorial.
- The pushbutton on the development board is connected to pin P6.1. The state of the pushbutton can be read in a similar manner.