24
ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Embed Size (px)

Citation preview

Page 1: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

ECE 3561 - Lecture 1 1

Code Composer

Department of Electrical and Computer EngineeringThe Ohio State University

ECE 2560

Page 2: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

ECE 3561 - Lecture 1 2

The Code Composer

Code ComposerAn interactive compiler, assembler, debug

system for development of programs for the MSP 430.

Developing an assembler program in Code Composer

Demo of a simple program

Page 3: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Documentation

You can bring up “help” in CCSBrings up a new windowYou can do a search on assembler

language or 430 Compiler Users GuideClick at top of page on Compiler Version x.x

User’s GuideWill allow you to navigate to assembler

Language tools users guide In 1.1 is the diagram

ECE 3561 - Lecture 1 3

Page 4: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

A top level view

Where assembler language fits

As the assembler is part of a code development system it is more sophisticated than typical assemblers.

ECE 3561 - Lecture 1 4

Page 5: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

CCS assembler

Using code composer for assemblerLaunch CCSSelect New ProjectGive the project a nameEnd name with .asmOutput type – leave as ExecutableChoose a location by unclicking ‘use

default’ and select your directory

ECE 3561 - Lecture 1 5

Page 6: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

CCS starting project (2)

In the device areaChoose the MSP 430 for Family:

Most likely this is the only optionVariant: Leave 1st box blankVariant: 2nd Box should be MSP430G2553

This is the 430 that is on the launchpadAs we will be using the debugger this is very

importantShould be USB1 – the default

ECE 3561 - Lecture 1 6

Page 7: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Under Advanced

You need to have the correct linker command file –

Here : lnk_msp430g2553

When selected – click OPEN

ECE 3561 - Lecture 1 7

Page 8: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Under Project Templates

Choose Empty Assembler-only Project

Click on Finish

ECE 3561 - Lecture 1 8

Page 9: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

The first window for project

Have several areasProjectCodingProblems

ECE 3561 - Lecture 1 9

Page 10: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Some first code

For first coding load values into some registers$0004 into R4$F012 into R5$0066 into R6

ECE 3561 - Lecture 1 10

Page 11: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

The project name

Rename main.asmGo to the Project Explorer WindowExpand it and you will see main.asmRight click, choose rename and do a

renameYou will see the new_name.asm at the

top of the coding window now.BE SURE YOU HAVE .asm extension

ECE 3561 - Lecture 1 11

Page 12: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

The coding window

Time to enter codeDiscussion of code sectionsEntering code - get some free lines first

END CODE WITH INSTRUCTION Loop: JMP Loop

This is so the program ends. This instruction is called an endless loop.

ECE 3561 - Lecture 1 12

Page 13: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

First Instructions

Assembler instruction formatLabel: Instr op1,op2 ;comment

They are MOV #0x0004,R4 ;comment MOV #0xF012,R5 ;note # sign MOV #0x0060,R6 ;note hex representation MOV R4,R7

Enter and compile

ECE 3561 - Lecture 1 13

Page 14: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Chip demo

Now compile and download to chip

Connect the launchpad

Choose DEBUG under RUN selection

New window format appears

ECE 3561 - Lecture 1 14

Page 15: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Run code

Can run code to end or step instruction by instructionSTEP can be done by using F5 as seen in

RUN menuAlso want to watch registersExpand the core registers listing

NOTE: window is CCS Debug – also have the CCS Edit which may be hidden

ECE 3561 - Lecture 1 15

Page 16: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Watch the action

Can see PC incrementingCan see SP being setCan see values loaded into registers

ECE 3561 - Lecture 1 16

Page 17: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

So what is this showing use

When executing To restart your code you can do a hard reset

The initial instructions CLR Rx - clears register x to 0’s

Register Mode MOV #0xFOO4,R4

Immediate addressing mode MOV #0x0060,R6

Another immediate addressing mode instruction Note way in which hexadecimal is specified

ECE 3561 - Lecture 1 17

Page 18: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

More on addressing

MOV R4,R7 Register mode – Copies the value in R4 to R7

so they have the same valueMOV R7,&buf

Move the contents of R7 to the address indicated by buf. buf is user defined symbol and has a value (next slide)

What is the value of buf MOV #buf,R6 shows what the value of buf is Note that buf has a value of 200 And that value is in R6

ECE 3561 - Lecture 1 18

Page 19: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Data/variables for your progam

Where is “buf”?To set up the area for

variables/constantsAfter your code, i.e., after Loop: JMP LoopStart line .data buf .word 0 vals .byte 14,3,12

ECE 3561 - Lecture 1 19

Page 20: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

The other addressing modes

Indirect Register ModeExample MOV @R6,R4

Note that the address of buf is $0200 and it has been loaded into register R6

The memory location at address buf has contents $F004

Note R4 after execution

ECE 3561 - Lecture 1 20

Page 21: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Indexed mode addressing

First clear the registersMemory was set up as follows

Address lbl contents0234h d1 0011h 0022h0238h d2 0033h 0044h023Ch d3 0055h 0066h

ECE 3561 - Lecture 1 21

Page 22: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Indexed addressing mode

MOV 2(R4),R6This should move the contents of the word

stored at 2 past the value in R4R4 contains value 0234h which labeled d1At memory address 0234h 0011hAt memory address 0236h 0022h

So instruction should move 0022h to R6

ECE 3561 - Lecture 1 22

Page 23: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

Indirect autoincrement

Do some loading of R7 using R4 with autoincrement.

MOV @R4+,R7

Can watch this in emulation on a chip

ECE 3561 - Lecture 1 23

Page 24: ECE 3561 - Lecture 1 1 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 2560

ECE 3561 - Lecture 1 24

Summary - Assignment

Saw an initial demo of how to use CCS

A look aheadWill cover some basics on instructions - Like

What is the instruction to load a value of 7h into R8?

Write the instruction to add R4 to R9 with the result going to R9.

HW 2 is on the webpage