We are going to use a software simulation of a PICmicro running C programs to help explain how C and the PICmicro work. While you can't create your own programs to run inside the CPIC you can interact with the ones which we have created.

Controls
On the right hand side you can see a CPIC holding an short program. If you press the GO button the CPIC will step through each line of the text in sequence. Pressing RESET will take you back to the start and pressing STEP will stop the programming running and allow you to step through a program one line at a time.

Source Code Window
In the top window you will see the C source which is being demonstrated. A white line highlights the line that the program has reached. You can use the up and down buttons to scroll the source up and down if it won't all fit in the window.

Variable Window
Below source code window there is another window which is used to show you the names and contents of any variables which have been declared. What appears here depends on what the program above does.

Input/Output Ports
Below the variable window is a row of buttons which can be used to set the input signal to each of the port bits on the PICmicro. The PICmicro has 13 connections which can be used as inputs or outputs, depending on how the PICmicro is configured. You can press the buttons to toggle the state of a pin if it is set as an input. At the moment all the pins are configured as inputs and so you will find that if you press a button the status indicator for that pin will turn red.

If a port was configured as an output you would be unable to change the indicator by pressing the button.

Data Direction Indicators
You can tell which are outputs by the direction symbol beneath the status indicator. If this points down it means that the pin is sending a signal to the PICmicro. (i.e. the pin is an input). If the symbol points up this means that the PICmicro is driving the pin as an output.

PICmicro Registers
Below the input/output ports is an area where the PORTA, PORTB, TRISA, TRISB and STATUS registers of the PICmicro are displayed. These are internal registers which control how the PICmicro works and interacts with the outside world. The meaning of these is explained later in the course.