EEGR-417-001, Micro Applications – Using the CCS Compiler

Introduction.

The PICKit2 we are using is very new.  After days and days of fiddling with the CCS compiler, my conclusion is that we can use MPLAB and the PICKit2 to compile and download using the debugger.  Although we can see the disassembly listing, there is no source level debugging capability.  That is, we can’t set breakpoints, look at the SFRs and watch variables.

However, I do want you to pay attention to the .LST file in terms of the assembly written by the compiler.  I will ask you to explain aspects during demos and this will be the primary focus of the oral final.

But, we can quickly compile, download and run, and afterall, that is the only capability we had with the DEV-CPP compiler on the PCs for EEGR-409.  So, we will have to live with this lack of debugging capabilities by judiciously using printf statements in our code.

For example;

      printf(ser_char, “%x %x?n”, ADRESH, ADRESL);

   printf(ser_char, “*”);

 

Preparation.

At http://www.phanderson.com/morgan, there are a number of C files including defs_887.h and ex_1, ex_2, ex_3 and ex_4.c. 

Copy these to your flash drive.  Use a simple subdirectory such as f:\micro.  Long and complex path names waste a lot of time.

Review these routines.  Note that the info at the top is always the same;

#case

#device PIC16F887 *=16 ICD=TRUE

 

#include <defs_887.h>

 

void ser_char(char ch);

void ser_init();

void delay_10us(byte t);

void delay_ms(long t);

 

Note that the ser_init, ser_char, delay_ms and delay_10us have been done for you.  All of these routines are important in every routine you prepare.

 

Project.

 

You can use MPLAB as an editor and it is always a good idea to start with an existing file, rename it and then modify to suit the requirements.

 

Once you are done, in MPLAB, go to project.  New Project.  Here, you will want to enter the name of your project, say PHA1 and the path name, say f:\micro

 

Be sure the Language Tool Suite is CCS PCM and the path is c:\Program Files\PICC.  This is where the C compiler is located.  Under Build Configuration, select Debug.

 

Under Build Options, CCS, be sure the List File is Normal CCS, the Debug is COFF format, Other Files, check all of them.  Under Device Family, leave blank.

 

Now, Add to Project and add your .c file.

 

Now, Build All (or Compile).  You may have to go back and correct any errors. 

 

When successful, go to Debugger, Select PICKit2.

 

At Debugger, Program.

 

And, you can use the F9, F5 and F6 keys to Run, Halt and Reset.

 

When you are completed, Save Workspace.

 

More.

 

When you return to the lab, you can avoid having to repeat all of this by simply loading the Workspace.

 

If you write a new program, go to Project, Remove the old C file and add the new one.

 

Conclusion.

 

The lack of source level debugging is a disappointment to me, but we can live without it. 

 

All of the above may appear somewhat cryptic and I may have made a typo of two.  It is best if you try it out on a program that you know works such as EX_1.C.