Cse/ee 470/570: Microprocessor-Based System Design Winter 2007 Lab 2 Pre-Lab Assignment



Download 13.63 Kb.
Date28.01.2017
Size13.63 Kb.
#9801
CSE/EE 470/570: Microprocessor-Based System Design -- Winter 2007

Lab 2

Pre-Lab Assignment


  • Read the section in the textbook related to both ASM and C programming.




  • Read the following materials to get ready for Lab 2.

    • CodeWarrior IDE Manual.

The file name is “8_16bit_IDE_Users_Guide.pdf”, which is located under CodeWarrior installation directory, usually usually C:\Programm Files\…\ Help\pdf.


    • CodeWarrior Debugger Manual.

The file name is “Debugger_HC12.pdf”, which is located under CodeWarrior installation directory, usually usually C:\Programm Files\…\ Help\pdf.


  • Pre-Lab questions:

    • Draw the detailed flow chat of finding the maximum of 8 digits between $0 and $F.

    • Draw the detailed flow chat of finding the minimum of 8 digits between $0 and $F.

    • Figure out the corresponding hexadecimal values of PORT A for displaying “0” to “F” on the 7-segment display.

Lab Assignment

Purpose

  1. To get familiar with the basic concepts of both ASM and C programming, and develop a simple languang (ASM or C) project, and a mixed language (both ASM and C) project in CodeWarrior IDE.

  2. To develop a simple language (ASM or C) project in CodeWarrior IDE.

  3. To develop a mixed language (both ASM and C) project in CodeWarrior IDE.


Assignment

Lab2. Design the algorithm to find both the maximum and the minimum of given hexadecimal number set from $0 to $F, and display both the maximum and the minimum on the 7-segment display in a periodic way given below:

Step 1): the minimum is displayed for 1 second;

Step 2): the 7-segment is blank for half second;

Step 3): the maximum is displayed for 1 second;



Step 4): goes back to step 1 to repeat the process.

Lab2A. Design a simple ASM project to implement the task A on the S12UB board.

Lab2B. Design a mixed language project in both ASM and C to implement the task A again on the S12UB board: implement accurate delay half second/one second (Only software time delay is allowed here) in ASM and others in C language.
Hand in

  • Get your pre-lab answer signed by the TA before starting the lab.

  • Get your assembly and C code files signed by the TA after successfully finishing the lab.


Hints:

  • To expedite your lab process, download the skeleton file(s) from course website to replace same file(s) while building your project in CodeWarrior, then develop/design your own algorithm.

  • All the CodeWarrior help file can be found under its installation directory as mentioned in pre-lab. IDE manual and Debug manual are great helpful for doing labs and other projects.

  • Quick view of Debug:

The Debugger
The debugger is a very confusing program to look at. But for basic stuff, it's pretty easy to use. Above is a screenshot of the default debugger window when run from a C program. The default debugger for an ASM program is very similar, but it only has one Data Monitor and things are rearranged a bit. Below are the most common uses of the debugger's functions. The full documentation is around 700 pages long (yes, literally), so this should be a bit easier to read. However, if you wish to read it, it can be found in your HC12 CodeWarrior installation directory under Help\pdf\Debugger_HC12.pdf (a CHM version exists in the directory above it). For most installations, the full path is c:\Program Files\Freescale\CW for HC12 V4.5\Help\pdf\Debugger_HC12.pdf.
Also note that the windows may be a bit small when you first start the debugger. You can rearrange, resize, or close any of them as you feel fit. Your project setup will store the last window setup you gave it.
For all the stepping commands that deal with assembly and the assembly display itself, it's worth mentioning that these will be displaying assembly as the CodeWarrior compiler has generated it from your code, either ASM or C. Thus, while it will look similar to your ASM code, it will look nothing like your C code. It may not be beneficial to step through assembly statements if you're debugging a C program.


  1. Program Control Buttons: These buttons control what the program will be doing. These are quite useful, as your program needs to actually run at some point. From left to right:

    • Start/Continue: Starts your program running or continues it if you halted it previously. Note that the debugger's output windows may not be able to keep up with the board, so the displays may not match what is going on until you halt the program.

    • Step Into: Execute one source instruction. In ASM, this is usually one ASM statement. In C, this could be one individual comparison of a longer C statement.

    • Step Over: Execute one procedure. In ASM, this is usually one ASM statement. In C, this usually translates into one line of code. This is generally the one you want in C.

    • Step Out: Steps out of the current procedure. That is, if you are in a procedure due to a Step Into command, this will step out of it.

    • Assembly Step: Execute the next ASM step of code. Obviously, this has little relevance to an ASM program, but in a C program, it will ensure that only the next ASM step is executed.

    • Halt: (will be red when the program is running) Halts the program immediately. This lets you use the step buttons.

  1. Source: Shows where in your original source the program is right now. In ASM, this will nearly line up with the Assembly window. In C, this will just line up to what is being executed right now.

  2. Procedure: Attempts to list what procedure is currently running. If your C program does not have many functions in it, this will almost always say “main()”. In ASM, this will usually display the last label reached.

  3. Data Monitors: Display the contents of defined data variables. That is, any reserved memory byte or defined byte/word (rmb or dc.b/dc.w) in ASM and any declared variable (char, int, etc) in C. If you didn't explicitly define it, it won't show up here (besides some internally-defined variables).

    If a variable was changed in the most recent step instruction (when run in step mode), it will show up in red. Also, the debugger will attempt to automatically determine the best way to display the variables (hex, binary, decimal, etc). If it gets it wrong (it usually will), right click the variable you want to view in some other format, select “Format” from the list, select “Selected” and modify it. If you want to change them all, select “All” from the Format list.

    Note that C defines two of these windows and ASM defines one.


  4. Assembly: Shows what ASM statements are being run. In ASM, this will only differ from source in that it will translate any variable into its actual value. In C, this will show the ASM code that was generated by the compiler.

  5. Registers: Shows what all the registers currently are. Like in the Data Monitors, if a register was changed with the most recent step instruction, it will show up in red. Also like the Data Monitors, you can set what format you want the registers displayed in, but it usually gets these right on the first shot.

  6. Memory Map: Shows everything in memory right now. Memory is a bit big, though, so searching through it may take a bit of time. If you issue a command to search through memory in the Debug Console, it will show up here.

  7. Debug Console: Takes input and shows any output the chip is presently giving. As it looks by default, it's too small to do much with, so you may wish to resize this.

    There are many debug commands in the debug console. You may type “help” to see them all. The most common one you would want is most likely “spc”, which will jump the Memory Map to a specified area of memory. Simply type the address (with a $ for hex) and it will go there. For example, “spc $4000” will jump to hex address 4000.



Download 13.63 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page