22

OCaPIC: PIC microcontrollers programmed in OCaml

 4 years ago
source link: https://www.tuicool.com/articles/hit/2eMRzm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

OCaPIC: Programming PIC microcontrollers in OCaml

This project allows to run OCaml programs on PIC microcontrollers.

Meeting of two worlds

  1. The OCaml language:

    • High-level multi-paradigm programming language.

    • Type-safetiness, robustness (strong static type check).

    • Functional paradigm (first-class functions and closures).

    • Imperative paradigm (mutable data, loops).

    • Object-oriented paradigm.

    • Exceptions.

    • Modules and functors.

    • Parametric polymorphism.

    • Automatic memory management.

  2. The PIC microcontrollers:

    • PIC = Programmable Integrated Circuit.

    • Low power consumption: a few mW .

    • Low cost: a few dollars.

    • RAM memory: a few kB.

    • Flash memory: a few tens of kB.

    • Clock: a few MHz

How can PICs be programmed in OCaml?

  1. Write your program in OCaml.

  2. Compile the source code with the ocapic command.
  3. Test your program with the OCaPIC simulator (optionnal).

  4. Assemble the assembler file produced by ocapic (for example, with gpasm ).
  5. Transfer the resulting hexadecimal code to the PIC.

  6. Plug the PIC into a circuit, and run it!

OCaPIC Features

  • OCaml Virtual Machine implemented in PIC18 assembler (compactness of binaries + efficiency).

  • PICs supported: all of the PIC18 family.

  • Porting of a large part of the OCaml runtime and standard library.

  • PICs specific libraries: LCD display, EEPROM, high level serial connection facilities, interruption catching, etc.

  • Two PIC simulators for OCaml programs to test them before programming the PIC.

  • OCaml library to write a component simulator as an OCaPIC simulator plug-in.

  • Deadcode elimination (with OCamlClean).

  • OCaml bytecode compression.

  • Fully tested, actually works with real programs.

  • Library documentation: manpages included in thedistribution.

  • Atutorial is now available.

Authors

  • Project author and developper: Benoît Vaugon

  • Project supervisor: Philippe Wang

  • Project meta-supervisor: Emmanuel Chailloux

  • Contact : [email protected]


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK