VIC™ - A compiler for Microchip’s PIC® Microcontrollers
The vic
compiler can accept commandline options that mainly allow the user to
reuse code for other Microchip’s PIC® MCUs and modify the pragma
statements on the
fly.
Here is a list of the commandline options currently supported in both short and long form:
-h
, --help
:
This option displays the help message for the compiler.
--version
:
This option displays the version number of the compiler.
--list-chips
:
This option lists the microcontroller chips supported by the compiler.
--list-simulators
:
This option lists the simulators supported by the compiler.
--verbose
:
This option turns on verbose printing of the compiler during compile time. This is different
from the --debug
or --intermediate
options which are for the compiled code.
-d
, --debug
:
This option turns on internal debugging of the compiler’s parser. The user
should not have to use this option unless filing a bug report. It is mainly for
the developers.
-i
, --intermediate
:
This option embeds the intermediate code generated by the compiler into the
assembly outputs as comments. This can be used by the user to view how the
compiler generates code for the VIC™ statements and by the developer for
debugging code generation.
-o <FILE>
, --output <FILE>
:
This option tells the compiler to save the output to the FILE
argument provided. If the filename ends with .asm
the compiler only compiles
to assembly. If the filename ends with .hex
or anything else, the compiler
will compile to assembly and also try to link it to create a binary hex file to
be programmed onto the chip. However, if gputils
is not installed, only the
compilation to assembly will take place. If the user does not provide this option the compiler prints the assembly output to the screen(stdout
).
-p <MCU Target>
, --pic <MCU Target>
:
This is the most useful of all options where the user can compile a code
written for one type of Microchip’s PIC® MCU target for a different MCU target. This
enables the user to achieve the following goals:
--simulate
This has to be used along with the --output
option defined above as it
uses the compiled and linked file and starts the simulator gpsim
or any other
selected simulator with it. This
allows the user to quickly run everything from the same executable vic
without
having to type the simulator’s commands directly.
--supports <MCU Target>
:
This is similar to the -p
option above except that it does not compile any
code. It can be used by the user or any other external program to verify if a
certain MCU target is supported by vic
. If it is not supported, the code
cannot be compiled to that target.
--list-features <MCU Target>
:
This is similar to the --supports
option above except that it also lists
the features supported by the chip. This automatically turns on the --supports
option.
--chip-pinout <MCU Target>
:
This option draws the pin diagram of the chip on the terminal that it has
been invoked in. This allows for the user to quickly see how the pins are
arranged on a particular chip and what their names are, as per feature.
Here is an example of the pin diagram of the PIC16F631
chip.
+======__======+
Vdd ---|1 20|--- Vss
| |
RA5/T1CKI/OSC1/CLKIN ---|2 19|--- RA0/C1N+/ICSPDAT/ULPWU
| |
RA4/T1G/OSC2/CLKOUT ---|3 18|--- RA1/C12IN0-/ICSPCLK
| |
RA3/MCLR/Vpp ---|4 17|--- RA2/T0CKI/INT/C1OUT
| |
RC5 ---|5 16|--- RC0/C2IN+
| |
| P16F631 |
| |
RC4/C2OUT ---|6 15|--- RC1/C12IN1-
| |
RC3/C12IN3- ---|7 14|--- RC2/C12IN2-
| |
RC6 ---|8 13|--- RB4
| |
RC7 ---|9 12|--- RB5
| |
RB7 ---|10 11|--- RB6
| |
+==============+
--list-gputils
:
This option lets the user know where the gpasm
and gplink
tools are
located on the current system for the gputils
package. The vic
compiler
checks the system install paths as well as any installs done by
Alien::gputils
.
--no-hex
:
The vic
compiler automatically looks for gpasm
and gplink
to create
the appropriate .hex
file for use by the pk2cmd
or other programming
software. If the user does not want to generate the .hex
file then they should
use this option. This is especially useful if gputils
is installed and the
user does not want to compile the .hex
file.
Based on these options here are some sample examples on how to use them:
# to print the compiler version
$ vic -V
# to print the help message
$ vic -h
# to compile to a hex file
$ vic -o helloworld.hex helloworld.vic
# to compile to assembly
$ vic -o helloworld.asm helloworld.vic
# to compile to a hex file but override the chip in the code
$ vic -p p16f631 -o helloworld.hex helloworld.vic
# to compile only to assembly with intermediate code and not to a hex file
$ vic -i -o helloworld.asm helloworld.vic
$ vic -i -o helloworld.hex --no-hex helloworld.vic
# to compile to a hex file and simulate the code
$ vic -o helloworld.hex --simulate helloworld.vic
# to list the chips supported
$ vic --list-chips
# to list the simulators supported
$ vic --list-simulators
# to check if the chip is supported
$ vic --supports P12F683
# to list the chip's features
$ vic --list-chip-features P16F685
# to print the chip's pin diagram
$ vic --chip-pinout P16F631
# to print the locations of the gputils tools
$ vic --list-gputils
Now that we have learned enough about using the vic
compiler, let us move on
to studying the various available in-built functions for VIC™.
Vikas N Kumar (@vikasnkumar) is the author of VIC™. All copyrights belong to the author and Selective Intellect LLC.
VIC™ is licensed under the license terms of Perl.
The development of VIC™ is sponsored by Selective Intellect LLC.
This page was last updated on 2014-12-02 10:39:14 -0500.