AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
By referring to the.asm output we can see what to expect when we start stepping through the application in the simulator (disable the watch dog and set the the primary oscillator configuration): bcf vwdtcon, 0,vaccess.Archive Content This post was written when I was running my dev agency Mangrove Root Limited.Old content The content is somewhat out of date thus your mileage may vary with the relevance of the instructions here Having been an electronics hobbyist in the past I have amassed a large collection of components and, while the temptation is to simply buy a few more Arduino boards and shields, in the spirit of waste minimisation and reuse I am trying to repurpose some of these existing components into my smartdesk.I happen to have a pair of Microchip PIC18F4550 microcontrollers and wish to use them, so first point of call is setting up a development environment for these devices.
Programming language, compiler and simulator Microchip provide a development environment ( Mplab X ) based on Eclipse. This would be an obvious choice, however I also wanted to explore the possibility of using open source tools instead. In terms of programming language for developing for the micro I wanted to find something slightly higher level than the PIC assembly language, preferably a C-like language (or C itself) but anything else with good support, and importantly, easy of use and rapid development. Legacy Peripheral Libraries For Mplabx Software Simulator ForMy research led me to the following: gpsim describes itself as a full-featured software simulator for Microchip PIC microcontrollers distributed under the GNU General Public License. JAL (Just Another Language) described itself as JAL (Just Another Language, version 2) is an open source programming language built for programming PIC microcontrollers. If electronics is your thing, JAL is for you jallib is a collection of open source libraries in JAL for PIC micros. Including libraries of code to use the various peripheral hardware these micros provide. It also includes definition files for all the PIC micro family. I ended up not choosing to use C, primarily because experimenting with JAL appealed to me, however SDCC would have been the primary choice for compiler and IDEs and other tools for C abound (only problem is I understand the SDCCs support for 16 bit architecture PICs is still in development, but usable). Legacy Peripheral Libraries For Mplabx Mac OS X Out OfCompiling JALv2 for Mac OS X Out of the box the source code for the JALv2 compiler (at time of writing version 2.4q5) will not compile with on Mac OS X (in my particular case using the XCode development tools I have Apple LLVM version 7.3.0). Luckily some simple and probably very unorthodox tweaks (hacks) we can get it into a working state (however no guarantees on how well it will work). Legacy Peripheral Libraries For Mplabx Archive Manually OrThe following assumes you have wget, if not either download the source archive manually or install wget with homebrew: mkdir jal; cd jal. The 2 changes we need to make are to relax some errors back to warnings and to fix a pointer type cast to avoid setting a null pointer. ![]() CFLAGS-O0 -ansi -pedantic -W -Wall -Wshadow -Wcast-qual (DEBUG) (PROFILE) (COVERAGE). ![]() These includes are part of the large standard library that jallib provides us with. By default the JAL compiler will produce all of the following outputs next to the original.jal source file:.asm: The resulting MPASM dialect assembly code for the PIC. If you open the this you will see that the compiler also emits the original JAL code as source comments.This is very useful to understand the mapping when debugging..hex: The compiled machine code in the Microchip Hex format. This site states it is an extended Intel Hex file with code, data, configuration bytes and user ID included.cod: The compiled machine code in a Byte Craft Limited COD format (or symbol format). Running the example PIC 18F4550 program Using gpsim we can run and test the PIC machine code generated by JALv2. The command line tool is easy enough to use an the build in help is invaluable gpsim.
0 Comments
Read More
Leave a Reply. |