Code Composer Department of Electrical and Computer Engineering ECE 2560 Code Composer Department of Electrical and Computer Engineering The Ohio State University ECE 3561 - Lecture 1
The Code Composer Code Composer An 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 ECE 3561 - Lecture 1
Documentation You can bring up “help” in CCS Brings up a new window You can do a search on assembler language or 430 Compiler Users Guide Click at top of page on Compiler Version x.x User’s Guide Will allow you to navigate to assembler Language tools users guide In 1.1 is the diagram ECE 3561 - Lecture 1
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
CCS assembler Using code composer for assembler Launch CCS Select New Project Give the project a name End name with .asm Output type – leave as Executable Choose a location by unclicking ‘use default’ and select your directory ECE 3561 - Lecture 1
CCS starting project (2) In the device area Choose the MSP 430 for Family: Most likely this is the only option Variant: Leave 1st box blank Variant: 2nd Box should be MSP430G2553 This is the 430 that is on the launchpad As we will be using the debugger this is very important Should be USB1 – the default ECE 3561 - Lecture 1
Under Advanced You need to have the correct linker command file – Here : lnk_msp430g2553 When selected – click OPEN ECE 3561 - Lecture 1
Under Project Templates Choose Empty Assembler-only Project Click on Finish ECE 3561 - Lecture 1
The first window for project Have several areas Project Coding Problems ECE 3561 - Lecture 1
Some first code For first coding load values into some registers $0004 into R4 $F012 into R5 $0066 into R6 ECE 3561 - Lecture 1
The project name Rename main.asm Go to the Project Explorer Window Expand it and you will see main.asm Right click, choose rename and do a rename You will see the new_name.asm at the top of the coding window now. BE SURE YOU HAVE .asm extension ECE 3561 - Lecture 1
The coding window Time to enter code Discussion of code sections Entering 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
First Instructions Assembler instruction format Label: 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
Chip demo Now compile and download to chip Connect the launchpad Choose DEBUG under RUN selection New window format appears ECE 3561 - Lecture 1
Run code Can run code to end or step instruction by instruction STEP can be done by using F5 as seen in RUN menu Also want to watch registers Expand the core registers listing NOTE: window is CCS Debug – also have the CCS Edit which may be hidden ECE 3561 - Lecture 1
Watch the action Can see PC incrementing Can see SP being set Can see values loaded into registers ECE 3561 - Lecture 1
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
More on addressing MOV R4,R7 MOV R7,&buf What is the value of buf Register mode – Copies the value in R4 to R7 so they have the same value MOV 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
Data/variables for your progam Where is “buf”? To set up the area for variables/constants After your code, i.e., after Loop: JMP Loop Start line .data buf .word 0 vals .byte 14,3,12 ECE 3561 - Lecture 1
The other addressing modes Indirect Register Mode Example 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
Indexed mode addressing First clear the registers Memory was set up as follows Address lbl contents 0234h d1 0011h 0022h 0238h d2 0033h 0044h 023Ch d3 0055h 0066h ECE 3561 - Lecture 1
Indexed addressing mode MOV 2(R4),R6 This should move the contents of the word stored at 2 past the value in R4 R4 contains value 0234h which labeled d1 At memory address 0234h 0011h At memory address 0236h 0022h So instruction should move 0022h to R6 ECE 3561 - Lecture 1
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
Summary - Assignment Saw an initial demo of how to use CCS A look ahead Will 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 ECE 3561 - Lecture 1