VIC™ - A compiler for Microchip’s PIC® Microcontrollers


Project sponsored by Selective Intellect Hosted on GitHub Pages — Theme by mattgraham

Table of Contents Prev  Next

Installation

There are two easy ways to install VIC. One is using CPAN and the other is from source.

Pre-requisites

You will need an operating system that supports Perl, such as Linux®, FreeBSD, OpenBSD and Apple® Mac OS X.

For Microsoft Windows®, you can download Strawberry Perl.

The minimum version of Perl required is 5.10.0. (It may work with earlier Perl versions but there are no guarantees.)

You will also need git installed if you're downloading the code from Github.

Supporting Applications

To make full use of VIC™ you need to install the following applications as well:

Installing from CPAN

This is the simplest way to install the release versions of VIC into /usr/local of your Unix-like system.

$ sudo cpan -i VIC

On Microsoft Windows®, you can install using the below command from the Strawberry Perl command shell.

> cpan -i VIC

Another way to install from CPAN is to use App::cpanminus, which may be available on your operating system or Perl installation. If it is not available, you could install that as well using the cpan client.

> cpan -i App::cpanminus
> cpanm VIC

Building from source

You may need to install the Perl package dependencies first which are done as below.

Download the software from Github.

$ git clone https://github.com/selectiveintellect/vic.git
$ cd vic
$ perl ./Build.PL --install_base=/usr/local/
$ ./Build test
$ sudo ./Build install

Dependencies

This module depends on the following:

You may need to install the Perl package dependencies first which are done as below:

$ sudo cpan -i Moo Pegex App::Prove File::Which Capture::Tiny

or using App::cpanminus

$ cpanm App::Prove
$ cpanm Pegex
$ cpanm Moo

The user should also install Alien::gputils on their operating system:

$ cpanm Alien::gputils

This will install the gputils package if not already present on the system. For Windows, they will need to download the installer from the link given earlier and then install Alien::gputils.

Testing the Module (Developers Only)

To test you will need to have App::Prove installed if you're developing the software

$ prove -lv t

Another option is to use Build.PL

$ ./Build test

Vim Syntax Highlighting

The installation provides syntax highlighting for the Vim editor.

The syntax for VIC is available in the file share/vic.vim in the source repository or in the share directory of the installation. You can place it in $HOME/.vim/syntax on Linux, FreeBSD, OpenBSD and OS X, and in $HOME/vimfiles/syntax on Windows systems.

Compiling examples

The examples are in share/examples folder. To compile the helloworld.vic example you can do the following:

$ ./bin/vic ./share/examples/helloworld.vic -o ./share/examples/helloworld.asm

This will generate the PIC® assembly for the VIC file.

$ ./bin/vic ./share/examples/helloworld.vic -o ./share/examples/helloworld.hex

This will generate the PIC® binary hex file ready to be programmed on to the chip.

Placing vic in your $PATH for Makefiles

If you are installing VIC in a local directory, you may need to set it in the $PATH variable for your system.

Testing on PIC microcontrollers on Linux and Mac OS X

The helloworld.vic test is for the Low Pin Count Demo board from Microchip and uses the PICKit 2 Starter Kit programmer to write to the microcontroller P16F690 on the board.

You will need to have gputils and gpsim packages installed on Linux or Mac OS X.

For Mac OS X, you may need to use MacPorts to easily install the gputils and gpsim packages.

$ cd share/examples/
$ gpasm -pP16F690 -M -c helloworld.asm -o helloworld.o
$ gplink -q -o helloworld.hex helloworld.o

This will produce a helloworld.hex file which you will have to write to the microcontroller using PICKit2 programmer from Microchip. You could use any other programmer as well as long as you have the right software for it. To write to the microcontroller on Linux or Mac OS X you need to have pk2cmd installed, as mentioned here.

To write to the microcontroller run the following:

$ pk2cmd -PP16F690 -M -Fhelloworld.hex

To run the test and have the microcontroller execute the code on the Low Pin Count Demo board to turn on the LED,

$ pk2cmd -PP16F690 -T

To stop the test and turn off the LED,

$ pk2cmd -PP16F690

To erase the code from the microcontroller,

$ pk2cmd -PP16F690 -E

NOTE: All the above have been implemented in a GNUmakefile present under share/examples/GNUmakefile.

Testing on PIC microcontrollers on Windows

For Windows, we currently recommend using the Microchip provided IDE. You can use VIC to generate the assembly files which you can then load into the IDE as part of your project and use.

You may choose to use Piklab as your IDE instead.

If you want to use Cygwin to perform builds using gpasm and pk2cmd you may do that and let us know if you succeed so we can write instructions for other users.

Recompiling the grammar

This is for VIC developers only.

To recompile the grammar into lib/VIC/Grammar.pm run,

$ ./share/rebuild-grammar

or

$ ./share/rebuild-grammar.PL

or

$ perl ./Build.PL
$ ./Build

All of the above do the same thing.


Table of Contents Prev  Next

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.