I do some C programming for PIC microcontrollers at work. Some time ago, I developed a "PIC" C AppWizard (under MS-Visual Studio v6) to create C PIC applications. Now I've decided to make it a Win32 "regular" executable so the wizard does not depend on Visual Studio IDE.
This PIC-C Wizard creates C code templates to be used for certain Microchip (tm) PIC microcontrollers using the Hi-Tech's PICC compiler (tm). I know these two issues limit the usability of the tool, so I hope someone finds it useful.
The demo files provided are part of a demo PIC C project created using this wizard.
- GUI interface to assist the user setup PIC's hardware and software.
- Creates C code templates that can be compiled with PICC (tm) compiler for the embedded version and Visual C/C++ for the PC version of the PIC's application.
- Handles different users.
- Creates a basic make batch file for PICC compilation and a project file (.dsp) for MS Visual C/C++ v6.0.
- User can add or remove PIC micros by editing a text information file (PIC.INF).
- Users can modify, add and/or remove the default C templates, so the wizard generates C code with the user's programming style.
- It includes basic source code comments to create documentation using doxygen.
To be honest, all these features are not yet implemented 100% and the wizard may still be "buggy". I'll be posting frequent updates as I'm still working on it.
I have not yet created an installer for this tool. So for now, simply download it and place it under a folder of your choice. I have tested it under Windows XP, 2K and NT SP6.
How This Wizard Works
User's folder and default C template files
The wizard will create a folder under the wizard's root folder. This folder will be named:
Templates_<username>. For instance, if the actual logged on user is trinity, the folder created will be:
Templates_trinity. This is where the wizard will put the default C templates and configuration files used to create PIC applications for different users. If a user's folder has been removed for some reason, the wizard will create it again with default templates.
The user can modify these C templates and the wizard will just replace the macros contained in them.
This is a list of the files generated by the wizard:
Common to both PIC and PC:
- pic.h: this file will be included in the sources and it'll load the PICC's pic.h or picpc.h (for Win32).
- main.h: this file will be renamed to the application's name. The user can add all sorts of definitions in this file that are specific to the application.
- main.c: this file will also be renamed. It'll contain the C
main() entry point and the interrupt vector, as well as a default program structure based on a simple tasks scheduler. The user can add code to this file that is specific to the application.
- typedefs.h:this file will contain common definitions to both the embedded and Win32 versions of the application.
- picpcproj.inf: this file contains what template files will be part of the application's project. It contains a brief explanation on the keywords to indicate to the wizard, how to create the project files.
- confirm.inf: it contains the text information to be displayed just before the creation of the project files.
- pic.inf: it contains the list of PIC microcontrollers that are going to be listed for selection. This file can be modified to add or remove micros. The information required to add a new microcontroller can be obtained from a Microchip's Product Line Card.
For PIC compilation:
- picc.h: it will contain definitions more specific to the PIC rather than the application.
- picc.c: it will contain code implementation of different support functions for PIC programming, depending on which options the user selected to create the application.
For PC compilation:
- picpc.h: it will contain definitions more specific to Win32 programming.
- picpc.c: it will contain code implementation of different support functions trying to simulate some of the PIC 's peripherals. Mmmh, didn't get much with this.
You may be wondering, why is there a Win32 version of an application that is supposed to go into an 8-bit micro? Because the idea was to debug the application, to some extent, before actually downloading the zeros and ones into the micro. The idea made some sense to me before, as it's easier to debug under VC. But quickly I learned that I lack the time and knowledge to simulate the PIC's peripherals.
Well, at least it helps me to debug certain applications using floating-point based algorithms.
How does the wizard create a PIC application?
Since I've used the Visual C/C++ AppWizard several times, my brain could not think of another good way to implement one, but to imitate the way MS-VC does it. Of course my implementation falls short compared to the real one but I think it does the job. So this wizard basically looks for special words, called macros, in all the template files and replace them with values provided by the user through the GUI interface.
One clear advantage of this wizard is that the C templates are open for the user to modify. It makes sense, I mean, I provided these C default templates, which only reflects my limited experience in C programming; good enough for the novice user though. But for the expert, mmh, let's better have another look at that code.
Now, for someone to start modifying the default templates, it's necessary to know all the available macros and I'll include them in this article in the very near future.
Can the source code be modified to have another wizard?
Short answer is yes. Soon I'll provide more information on what and how to modify the source code provided to have another wizard.
How To Use
A tutorial will be coming soon...
What? You really think that the only cool things about the wizard were programmed by me? Of course not, I really must thank these guys for their great code: