ā¢ The rush of the first take off, which is performed by the instructor.
ā¢ The white-knuckled, sweaty grip on the yoke while trying to keep the plane flying straight for a couple of minutes, after the instructor gives the standard āanybody that can drive a car can do thisā speech.
ā¢ Acute motion sickness, as the instructor returns for the landing and performs a sickness-inducing maneuver, called the āside slipā, where it looks like the runway is coming through the side window.
For those who are new to the world of embedded programming, this first chapter will be no different.
Flight Plan
Every flight should have a purpose, and preparing a flight plan is the best way to start.
This is going to be our first project with the PIC24 16-bit microcontroller and, for some of you, the first project with the MPLABĀ® X IDE Integrated Development Environment and the MPLAB C language suite. Even if you have never heard before of the C language, you might have heard of the famous āHello World!ā programming example. If not, let me tell you about it.
Since the very first book on the C language, written by Kernighan and Ritchie several decades ago, every decent C-language book has featured an example program containing a single statement to display the words āHello Worldā on the computer screen. Hundreds, if not thousands, of books have respected this tradition, and I donāt want this book to be the exception. However, it will have to be just a little different. Letās be realistic, we are talking about programming microcontrollers because we want to design embedded-control applications. While the availability of a monitor screen is a perfectly safe assumption for any personal computer or workstation, this is definitely not the case in the embedded-control world. For our first embedded application we better stick to a more basic type of output ā a digital I/O pin. In a later and more advanced chapter we will be able to interface to an LCD display and/or a terminal connected to a serial port. But, by then we will have better things to do than writing āHello World!ā
Preflight Checklist
Each flight is preceded by a preflight inspection ā simply a walk around the airplane where we check that, among many other things, gas is in the tank and the wings are still attached to the fuselage. So, letās verify we have all the necessary pieces of equipment ready and installed/connected:
ā¢ MPLAB X IDE, free Integrated Development Environment (obtain the latest version available for download from Microchipās website at http://www.microchip.com/mplab)
ā¢ MPLAB C30 Lite Compiler v3.30 (or later) or MPLAB XC16 Lite Compiler
ā¢ A PIC24FJ128GA010 on a PIM (also known as a mezzanine board)
ā¢ An MPLAB X compatible programmer/debugger such as the PICkit3, ICD3 or Real ICE
ā¢ The Explorer16 board, or any demo board with a row of eight LEDs connected to PortA.
Letās follow the New Project Setup checklist to create a new project.
From the Start Page of MPLAB X, select Create New Project, or simply select File>New Projectā¦ from the main menu to activate the new project wizard, which will guide us automatically through the following six steps:
1. Choose Project: in the Categories panel, select the Microchip Embedded option. In the Projects panel, select Stand alone Project and click Next.
2. Select Device: in the Family drop box, select PIC24. In the Device drop box, select PIC24FJ128GA010, or other PIC24 model of your choice and click Next.
3. Select Header: simply click Next.
4. Select Tool: select the PICKit3, or other supported programmer/debugger of your choice, and click Next.
5. Select Compiler: select C30 (or XC16 if available), and click Next.
6. Select Project Name and Folder: type 1-HelloWorld as the project name, type C:\FlyingPIC24 as the folder name or use the...