MicroCode Studio ICD
project will introduce you to
the new MicroCode Studio In-Circuit Debugger, and show how to use the ICD
feature with the LAB-X3 PIC development board, and the PIC16F628. If you
don't have the LAB-X3 development board you can put together the required
hardware in a matter of minutes on a breadboard. A sample of the minimum
circuit required to use the ICD with the PIC16F628 is shown below in Figure
NOTE: If you don't have the new version of MicroCode Studio with the ICD feature, you can download it HERE. It's 100% FREE.
What Happens When You Run The ICD?
As your code executes on the target PIC16F628 microcontroller the ICD allows you to monitor changes made to system variables, special function registers (SFR), and even internal EEPROM memory. The hardware serial port or (USART) on the PIC sends this information to the PC serial port, and MicroCode Studio ICD organizes this data in the ICD Explorer Window as shown in Figure #1.
As your code executes, and internal calculations are performed on variables, you'll see the results of each calculation in the explorer window as shown below. Notice how the Identifier column [under Variables] lists variable names, and each value is shown in three formats. Decimal, Hex, and Binary.
If you were ever curious about how internal integer math calculations, or PicBasic Pro commands "really work", here's your ticket. Got questions? Type in your calculation or code, compile, program the target device, and view the answers in real-time, on-screen.
NOTE: Values shown in the Explorer window (are not) calculated by the MicroCode Studio ICD software. The target PICMicro running your application code in real-time sends everything directly to your PC serial port from "inside" the microcontroller.
If you own the LAB-X3 board, you won't need to construct the circuit shown below in Figure #2. Connect your EPIC Plus programmer to the LAB-X3 board, and you can program the 16F628 in-circuit while running the MicroCode Studio ICD. If you don't own the LAB-X3 board, build the circuit shown below in Figure #2. The hardware interface using the MAX232CPE is required to send debug information from the PIC to your PC for display within the ICD Explorer window.
If you're wondering why the ICD doesn't support the PIC16F84, it's because this series does not have the internal hardware USART like the PIC16F628, and 16F87x series that's required by the ICD for proper operation.
The Need For Speed
The LB-X3 board is normally supplied with a pre-installed 4MHz crystal oscillator. The ICD will function fine at 4MHz, but will run slower. If you feel the "Need-For-Speed" you can build the circuit in Figure #2 with a 20MHz ceramic resonator with internal capacitors together with a PIC16F628-20/P for much faster in-circuit debugging. Owners of the LAB-X3 board can also replace the 4MHz crystal with a 20MHz crystal to increase performance. Just be sure that you use a PIC16F628-20 and not the PIC16F628-04 if you're using a 20MHz oscillator.
Why The Hardware Serial Interface.?
MicroCode Studio ICD uses the PIC hardware USART to send / receive serial data between the target PICMicro, and the ICD software. It will NOT run using other PIC I/O-pins.
OK. Now you have your LAB-X3 board ready or you've put together the circuit shown in Figure #2, and you're ready to get started using the MicroCode Studio ICD.
The first thing we need is some code to load into the 16F628 so we can see how the ICD works. Just as a quick example, I have included a simple routine below that will increase the size of variable Counter, and decrease the size of variable Junk within a tight loop. You won't need any external hardware connected since we're just going to view the internal manipulation of the two word sized variables.
Once you have saved the basic file, it's time to connect the LAB-X3 board [or similar circuit as shown in Figure #2] to your PC serial port. Apply power to the LAB-X3 board, or circuit, and the EPIC programmer. Before you compile the code example, be sure to select the PIC16F628, and an available com port as shown in Figure #3.
Notice in Figure #3 that I have also selected the EPIC programmer as the default programmer for MicroCode Studio to launch when I compile my code. You can select a different programmer if you have one. Just follow the instructions in the help file included with MCS to install a different programmer as needed. The down arrow next to the ICD Compile/Program button allows you to change the default programmer.
Once you have selected your default programmer, click the ICD Compile/Program button to compile the sample code, and launch the programmer software.
Assuming you didn't receive any errors during compile, you should now be staring at the programmer software screen as shown in Figure #4.
No errors..? Great. You're ready to program the PIC16F628 with your compiled .hex file. Click the program button to program the LAB-X3. If you're using the home-grown circuit shown above in Figure #2, you'll need to program the PIC16F628 with your EPIC or other programmer, then insert the 16F628 into the ICD interface circuit.
Assuming your home-made ICD circuit or LAB-X3 are connected properly, and everything's working, you should now be ready to close the programmer screen, and start the ICD. If you didn't get the 16F628 programmed correctly, re-trace your steps, verify all connections, and try again.
If you have successfully programmed the 16F628, you're ready to start the ICD and watch as your program runs in real-time on the target.
First click the ICD Pause button.
Next click the ICD Run button.
Next click the ICD Step button.
The Pause button allows you to start the ICD with animation running your code line by line. You can always just click the ICD Run button, but you'll miss things when the ICD first starts. This is especially true when running the target PIC at 20MHz since everything runs much faster than at 4MHz.
The ICD Step button executes a single line of PIC BASIC Pro code each time you press the button. To watch your code execute fully animated, simple de-select the ICD Pause button.
Here are sample screen-shots you'll see if you're running the sample code shown above for this project.
Now try running more of the sample programs included with the LAB-X3 board or other code samples you have. This introduction is just to help you get started.
Spend a few hours with the MicroCode Studio ICD to find out what you were missing. It comes in very handy.
The free version of MicroCode Studio supports the PIC16F628. For expanded device support [shown below], you'll want the MicroCode Studio Plus CD-ROM.
Until the next project - have fun - and don't blow anything up...;o]