Assignment #1

Objective:

The objective of this week is to become familiar with the navigation controls, the reset, single step, and play functions of the NECRobot.

References:

Any required references are on the NEC CD under the "Documents" link.

Procedure:

The student version of the tools are code size restricted, which in almost all cases should not pose any limitations. Everything you need is on the Student CD. You will need to load the Program manager, Relocatable Assembler, C Compiler, and Software Simulator. For the first five or six weeks, of assignments you will be working predominately in the C compiler and the Software Simulator. The last few weeks you will work with the actual hardware of the RobotRACER, the LCE (Low Cost Emulator), and flash programming tools. You will find instructions, coded sub-routines in folders designated by week.

Install the tools: Insert the CD and initiate the install routine. You can install just the Software Simulator and C Compiler at this time. Open up the Simulator and call up the Week 1 assignment. The objective this week is to learn the Simulators navigation controls, the reset, single step, and play functions. Follow these steps to open the test example and get familiar with the tools.

1) Through the start menu, choose Programs  NEC Tools  SM78K0S to open the simulator.

2) The configuration windows pops up; choose the 9418A chip, the sub-clock frequency to 32.768, and leave the defaults for the other fields.

3) Press O.K.

4) Go to File  Download and select the .lmf file in the directory that all of your project files are in.

5) The source code pops up and you can see all of the instructions in your program.

6) Notice the red asterisk on the left hand margin. To set break points, you click on these and a red 'B' indicates that when the code is run, if the flow gets to that instruction, the simulator will pause and you can see the state of the chip.

7) Go to File  Open  Week1.c in your project directory.

8) Set a break point somehwere in the code.

9) Notice that when the simulator is opened, another window appears minimized labeled 78K0S Simulator GUI.

10) Open this window and choose External Parts --> Panel Window

11) Go to File  Open  robot_layout.pnl

12) This opens the virtual hardware layout for the robot. Notice it has two push buttons - MODE and GO - just like the robot as well as the seven segment display. The Batt. v bar is for the battery voltage - the simulator can provide a voltage input into one of the pins. This is used through an analog-to-digital converter to check if the battery voltage is low.

13) Now go back to the main simulator window. Notice the CD player type buttons.

a) The play button runs your code until a breakpoint.

b) The pause button pauses execution.

c) The eject button reset the CPU.

d) The ">" button executes a single step, or one line of code.

e) The ">" button will execute a step, but not go into a function call. Useful if you know a function already works.

14) Now run the code using the play button. Click on the "GO" button on the simulator GUI and notice that the code stopped at your breakpoint in week 1.

15) Press the reset button and single step a few steps.

16) Learn to watch variables next by clicking on the watch button. Choose add and type in Mode_number (case sensitive). Click “add” and ok.

a) Any variable in the current program scope can be watched.

b) Hardware registers can be watched by typing in their exact names found in the manual. Example: P5 for port five, P5.0 for port five, bit zero.

17) Press the play button

18) Now click on the Mode button in the simulator GUI window. Notice how the mode button in increasing!

All of these skills will be very useful in the weeks to come. Whenever a piece of code doesn't work, make sure you very slowly step through it and watch exactly what is happening to the important variables and hardware registers.