Download Morse Code with Timers on the MSP430 Part 0: Installation (optional)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Immunity-aware programming wikipedia , lookup

Transcript
ELEC 327 (2014) Lab #1: Morse Code with Timers on the MSP430
Part 0: Installation (optional)
You are welcome to install CCS on your own personal computers. If you choose to do so,
follow the instructions in Lab 1 of the Student Guide.
Part 1: Verifying CCS and Launchpad Functionality
Compile the included lab1_skeleton.c file to verify that CCS is setup correctly. You should also
read through this file: it shows the minimum amount of code needed to set up a timer
interrupt on your MSP430. If you ever don’t know what some variable acronym means, look it
up! A useful practice is right clicking the name and going to “Open Declaration”. For instance,
in this file, doing this on MC_2 brings you to:
#define MC_2 (2*0x10u)
/* Timer A mode control: 2 - Continuous up */
What, then, does this continuous up mode mean? Two resources you should use extensively
are the MSP430x2xx Family User Guide and the MSP430G2553 datasheet, both of which can
be found on the main 327 page (or by googling). The user guide explains how to use various
functions or registers common to most MSP430s, while the data sheet has register values and
pin information specific to the G2553. So, searching for “MCx” on the user guide takes you to
Chapter 12, which explains the different modes of the MSP430 timers.
a) The MSP430 has multiple clocks a given interrupt timer can use to control itself. Look
up what clock TASSEL_2 selects, and what its default frequency is on our device.
b) Using the timer in continuous up mode as in the skeleton file, what is the frequency of
the timer interrupt routine?
c) Using the IDx variable, how could we halve this frequency?
Part 2: Blinking a Morse Code Message
Using the P1.0 LED on your launchpad, blink a message in morse code. Look morse code up
on wikipedia to find the code for each letter and how to separate letters. Submit your code in
a separate file named morse_code.c. A few specifications:
● A “unit” should be ¼ of a second.
● Use whatever clock and Timer mode you want.
● Organize your code such that to change the message, you only have to change one
array at the beginning of your program.
● Be able to display either “SOS” or the first 3 letters of your first name, depending on
which array is commented out.
● Your message should repeat.
● Consider repetitions of your message different words. This means that you should
have 7 “units” of off time between each repetition. If you want, this as well as spaces
between letters and parts of the same letter can be hard coded into your array.
● To help yourself write clean code, you should use “BITx” whenever you do anything
with a pin on the MSP430.
● BONUS [High Speed]: For those of you feeling particularly under-tasked by this lab,
extra credit will be given for a second implementation of code that runs as fast as
possible. Specifically, the goal is to minimize the “dot” time (the “dash” should be twice
the dot). You can use any and all tricks at your disposal (i.e., changing clock frequency,
using timers, etc), and should demonstrate the result using an oscilloscope.
Part 3: Moving it to a Breadboard
We’ll be working with a lot of input/output devices in this class, and so it makes sense to be
able to program an MSP430 on a breadboard so that it can run independently. Make this
breadboard wiring clean, as you’ll be testing a lot of circuits using it. To actually program the
MSP430 on a breadboard using the launchpad, you only need to:
1) Connect the TEST and RST pins on the EMULATION side of the launchpad to their
respective pins on the MSP430 (these are labeled on the launchpad where the MSP430
itself is usually located).
2) Connect Vcc and GND (or some independent battery, but for now use the launchpad’s
power) to their respective pins. For your convenience, jump these to the power lines
on the breadboard. To ensure a clean power supply to the MSP430, connect a 10uF
capacitor anywhere on the board between Vcc and GND.
3) Connect a pull-up resistor to the RST pin, as it is active-low. That is, connect a large
resistor (47K from lab is fine) from the RST pin to Vcc, to ensure that its default state is
high.
Now, reproduce your morse code circuit on the breadboard using LEDs and resistors in the
lab. There are, however, some differences you need to take into account:
a) What is the forward voltage on the LED? What is its maximum forward current?
b) What is the supply voltage coming out of the MSP430? On the MSP430G2553, what is
the maximum current any one pin can output?
c) Using all this, what is the resistor value you should use to supply exactly this maximum
current? To be safe when using the MSP430, should you use a larger or smaller
resistor?
Wire the circuit on your breadboard, and make sure to demo it successfully flashing.