Lab 1 - Warm

advertisement
Warm-up Lab
Lab 0 – Warm-up Lab
1. Acquire a Texas Instruments MSP430 LaunchPad
Development Tool.
2. Setup a CS user account.
3. Install (if necessary) and "run" blink.txt on the Digital
State Machine Simulator.
4. Install (if necessary) and execute TI's Code Composer
Studio (CCSv5.2).
a. Create a new assembly project. Load, assemble, and execute
blinky.asm on your LaunchPad development tool.
b. Modify blinky.asm to double the toggle speed of the LED.
c. Use Code Composer to create a new C language project.
Load, compile and execute blinky.c on your LaunchPad
development tool as well.
d. Modify blinky.c to double the toggle speed of the LED.
BYU CS 124
Lab 0 - Warm-up Lab
1
Warm-up Lab
Lab 0 – Warm-up Lab
1. Read again the Academic Honesty declaration.
Students are encouraged work
together in as far as discussing,
clarifying, and helping each other
understand material.
No lab source material should ever be
emailed to another student!
Please avoid even the appearance of
cheating by looking on another's monitor.
BYU CS 124
Lab 0 - Warm-up Lab
2
Warm-up Lab
Lab 0 – Warm-up Lab
2.
Acquire a Texas Instruments MSP430 LaunchPad
Development Tool directly from Texas Instruments (or
BYU Book Exchange, Amazon, Digikey,…).
BYU CS 124
Lab 0 - Warm-up Lab
3
Warm-up Lab
Lab 0 – Warm-up Lab
3. Setup a CS user account.



If you are using your own computer, you can still set
up your account.
If you are using a computer science department
computer, then you should already have an account
setup for you. (If you are setting up an account for
the first time you may need to use your RouteY ID as
your username and your student number as your
password.)
Note: you may be required to change your password
at this time.
BYU CS 124
Lab 0 - Warm-up Lab
4
Warm-up Lab
Lab 0 – Warm-up Lab
4.
Install (if necessary) and "run" blink.txt on the Digital
State Machine Simulator.
Toggles
on and off
Load
Blinky.txt
BYU CS 124
Lab 0 - Warm-up Lab
5
Warm-up Lab
Lab 0 – Warm-up Lab
5.
Install (if necessary) and "clock" control.txt on the
MSP430 micro-architecture simulator.
BYU CS 124
Lab 0 - Warm-up Lab
6
Warm-up Lab
Lab 0 – Warm-up Lab
6. Install (if necessary) and execute TI's Code Composer
Studio CCSv5.xx.
BYU CS 124
Lab 0 - Warm-up Lab
7
Warm-up Lab
Lab 0 – Warm-up Lab
7.
Create a new assembly-only project. Load, assemble,
and execute blinky.asm on your LaunchPad
development tool. Modify blinky.asm to double the
toggle speed of the LED.
;*******************************************************************************
;
CS 124 Lab 1 - blinky.asm: Software Toggle P1.0
;
;
Description: Toggle P1.0 by xor'ing P1.0 inside of a software loop.
;
;*******************************************************************************
.cdecls C,LIST, "msp430.h"
; MSP430
;-----------------------------------------------------------------------------.text
; beginning of executable code
RESET:
mov.w
#0x0280,SP
; init stack pointer
mov.w
#WDTPW+WDTHOLD,&WDTCTL ; stop WDT
bis.b
#0x01,&P1DIR
; set P1.0 as output
mainloop:
xor.b
mov.w
#0x01,&P1OUT
#0,r15
; toggle P1.0
; use R15 as delay counter
delayloop:
sub.w
jnz
jmp
#1,r15
delayloop
mainloop
; delay over?
; n
; y, toggle led
;-----------------------------------------------------------------------------;
Interrupt Vectors
.sect
".reset"
; MSP430 RESET Vector
.short RESET
; start address
.end
BYU CS 124
Lab 0 - Warm-up Lab
8
Warm-up Lab
Lab 0 – Warm-up Lab
8.
Use Code Composer to create a new C language
project. Load, compile and execute blinky.c on your
LaunchPad development tool as well. Modify blinky.c
to double the toggle speed of the LED.
//******************************************************************************
// CS 124 Lab 1 - blinky.c: Software Toggle P1.0
//
// Description; Toggle P1.0 by xor'ing P1.0 inside of a software loop.
//
//******************************************************************************
#include "msp430.h"
volatile unsigned int i;
// volatile to prevent optimization
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= 0x01;
// Stop watchdog timer
// Set P1.0 to output direction
}
for (;;)
{
P1OUT ^= 0x01;
i = 0;
while (--i);
}
BYU CS 124
// Toggle P1.0 using exclusive-OR
// Delay
Lab 0 - Warm-up Lab
9
Download