Microcontrollers: From Assembly Language to C Using the PIC24 Family

This site introduces students, educators, and hobbyists to the capabilities of a powerful modern microcontroller, the Microchip PIC24.


Microcontrollers: From Assembly Language to C Using the PIC24 Family covers a broad range of topics in a straightforward, conversational style accessible to students and hobbyists alike. Topics include PIC24 assembly language programming and hardware interfacing using the C language. The text introduces the PIC24 library collection and contains an extensive set of examples carefully explained in the text. The text then presents ESOS, a low-overhead operating system for the PIC24 and provides a capstone design chapter in which the designs of an audio record/playback system, reflow oven and a remote-controlled robot are presented. The book is available from Delmar Learning. A video tutorials page is also available that contains selected topics from the book.




                
The PIC24 library collection accompanying the text provides a tested, well-documented set of libraries illustrated by numerous examples which simplify many common programming tasks for the PIC24. The getting started guide provides all information necessary to get your PIC24 system up and running. With an operational system, the PIC24 support library
provides support for all major subsystems of the PIC24. The ESOS library contains a low-overhead, cooperative OS.





                                          
The ECE3724 course on microprocessors features on-line lecture notes and lab experiments which cover major portions of the text, including four assembly labs and 6 hardware labs, including experiments with a digital thermometer and fan speed control.




News

  • 3-Mar-2014: The code archive is updated, providing some bug fixes and cleanup. See the release notes for more details.
  • 9-Jul-2013: A new, beta release containing major updates to the code archive in the PIC24 library collection is available, featuring preliminary MPLAB X support, redesigned GPIO macros, and much more. See the release notes for more details.
  • 1-29-2013: Here are some notes on the flipped classroom approach that we use in our ECE3724 course.
  • 15-Aug-2012: There are more video lectures available for our ECE3724 course and more will be added as the Fall 2012 semester progresses.
  • 22-Mar-2012: The code archive has been updated to provide initial support for the PIC24E/dsPIC33E families, as well as some some bug fixes and cleanup. See the release notes for more details. This page discusses some of the differences between the PIC24H and PIC24E families.
  • 1-Mar-2012: The code archive is updated, providing some bug fixes and cleanup. See the release notes for more details.
  • 25-Aug-2011: The code archive is updated, providing some bug fixes and cleanup. See the release notes for more details.
  • 12-Apr-2011: The code archive is updated, adding support for two additional hardware platforms. See the getting started page for currently supported platforms and the release notes for more details.
  • 8-Apr-2011: The code archive is updated with a number of improvements and some significant changes. The common/, include/, and lkr/ directories have been moved to lib/common/, lib/include/, and lib/lkr/. All project files in the library have been updated with these new paths; use these as a template to upgrade your current projects.
  • Jan. 2011: The examples in the code archive have been updated so that all examples link with V3.25 of the MPLAB C Compiler for PIC24 and dsPIC in LITE mode. A few examples used printf statements with floating point formats, and these no longer link on devices with only 2K RAM (printf format strings are built in data memory) as the printf data buffer reserved by the compiler has greatly increased in this compiler version. On CPUs with greater than 2K RAM  the code examples work the same as before; on CPUs with 2K RAM (such as the PIC24HJ32GP202)  conditional compilation is used to select code that only uses printf statements with integer formats for output strings. Most of the affected code is in Chapter 11, such as chap11/adc2pots1.c or chap11/adc_test.c. The code update also includes a user-submitted fix for the Bully Bootloader when loading software greater than 64K (thanks John N. and Vaifro D.!).  Microchip has promised a fix for the printf data RAM buffer usage, and the printf code changes in the examples will be backed out once that fix is released.
  • Dec. 2010: Updated the wireless mesh technology demonstration with some bug fixes, additional documentation.
  • Sept. 2010: Updated the distribution to include older v2 linker files; documentation look updated.
  • August 2010: Added a new project about a wireless mesh technology demonstration that has a data node consisting of a Synapse RF Engine and a PIC24F microcontroller.
  • July 2010: Added a new book adopter, the United States Naval Academy, which will use the Microchip Microstick as the lab platform.
  • July 2010: The Bullly bootloader GUI and firmware in the code archive have been updated to version 3.0.  This is a significant update in that both the firmware and application GLD files have been changed to remap the interrupt vector table such that the bootloader space is never written during bootloading. Previously, memory page 0 was written during the download process in order to copy the application's interrupt vectors -- if this page write to page 0 failed, then a 'dead bootloader' could result. This costs an extra 0x200 in program space usage, and also a few cycles of extra latency in interrupt service. We had a few complaints of dead bootloaders, and so made this switch. The GUI will detect if it is connected to a bootloader of firmware version less than 3.0 and will do the old behavior. Because the application and bootloader GLD files now require more complex changes to them, a Python script is now included (code/bootloader/24h_24f_target/lkr/convert_gld.py) that will produce all necessary bootloader linker files (code/bootloader/24h_24f_target/lkr/*.gld) and application linker files (code/lkr/*.gld).  All of the PIC24H/PIC24F .gld files have already been converted for you as of July 2010, so there is no need to run the python script until Microchip releases new devices (and we will typically update the code archive with these new .gld files).
  • June 2010: The third installment of the MCHP TUbe series has been released, and it features 16-bit microcontrollers and educational materials, including our book.
  • June 2010: Microchip has announced the Microstick, a great educational platform for exploring the PIC24 family. This $25 board offers built-in PICKIT programming and debugging capabilities, making it the perfect laboratory platform for PIC24 microcontroller education.  This page has a video that shows how to use the Microstick with our book examples.
  • May 2010: Updated code archive header files for the PIC24F32GA102, PIC24F64GA102, PIC24F32GA104, PIC24F64GA104 devices. These are XLP versions (and other additional features) of the PIC24F64GA002/PIC24F32GA002 devices.
  • April 9th, 2010 -- The first video in the ECE 3724 lectures series is now available on the videos page.
  • April 2010: An oscilloscope tutorial video is now available.
  • On March 17, 2010, an MSU senior design team competed in the SECON 2010 student hardware competition and placed 3rd out of approximately 25 teams. The team used a a Microchip PIC24FJ128GA006 as its CPU. More information can be found here.
  • March 2010: The code archive (and the bootloader) was updated for the PIC24FJ64GB002/4, PIC24FJ32GB002/4 devices, which are USB devices. The clock configuration (common/pic24_clockfreq.c) and configuration bit (common/pic24_configbits.c) files were modified slightly, and the bootloader devices.txt file updated. Warning: Our default choices of RB10/RB11 for the UART pins clashes with the D+/D- USB pins on these devices, so you will have to chose different pins for UART RX/TX if you wish to use the USB port.
  • February 2010: The data transfer protocol, useful to debug a program, is available.
  • January 2010: New book adopter added to adopter page, code archive updated with a Bully bootloader GUI that now has a variable monitoring panel (documentation/video to be added soon).
  • Version v3.22 of the Microchip C compiler has fixed the compiler bug mentioned below. It is recommended that you update your compiler to this version.
  • WARNING -- C Compiler v3.20b bug!  --- a user recently notified us that ESOS examples (Chapter 14, chap14/app_echo1.c, chap14/app_reverse.c) did not work correctly. The problem was tracked to a C compiler optimization bug between optimization level 1 (some examples do not work correctly) and optimization level 0 (examples work fine). This bug was introduced with the C compiler V3.20 release that was made at the end of August, 2009, and has been verified by us in V3.20b and also 3.21(Beta).  To be safe, if you are using V3.20, then you should probably use optimization level 0 for all book examples until this problem is corrected by Microchip. Here is a thread on the Microchip forum that discusses the problem. To change the optimization level within MPLAB, use Project|Build Options|Project, then click on the MPLAB C30 tab. From the 'Categories' pulldown list, chose 'Optimization', and in the Optimization level graph, click on the circle to the far right. You should see the compiler option change from '-g -Wall -O1' to '-g -Wall'.  Optimization Level 1 is the default option, so you must manually change the optimization level in the project to select level 0.  UPDATE:  It appears that this bug will be fixed in V3.21B (or V3.22), see this thread.
  • October 2009:Code archive updated with initial support for the PIC24FK family (extra low power sub-family of the PIC24F). The bootloader and chap8/reset.c project has been tested with the 24F16K102 (available in a 28-pin DIP). Here are some notes on the PIC24FK family.
  • September 2009: Project page updated with a breakout board for 64-pin PIC24 CPUs.
  • September 2009:Code archive updated to add support for some dsPIC33 devices and to fix some incompatibility problems with the latest version of the C30 compiler (V3.20)
  • September 2009:Code archive updated, bootloader is now easier to retarget to different UARTs, added some more bootloader pre-compiled hex files and bootloader-compatible application linker files for different devices.
  • July 2009: Added a project on a vibration-compensated tilt sensor.
  • June 2009: The ASEE workshop was sold out with 23 attendees. The complete CDROM of training materials provided to the attendees can be downloaded here. Here is a ZIP archive that contains the schematic/board files for the PCB that was used in the training.
  • May 2009: Added a textbook supplement that discusses differences between ADC operation for PIC24 CPUs with and without DMA (the code examples in Chapter 11 use a PIC24 without DMA). Presents code examples for using the ADC with the DMA module; all referenced code examples are in the code archive.
  • April 2009: An earlier update to the code archive to warn users if a requested clock switch had failed caused a compilation error for ESOS projects; this has been fixed.
  • March 2009: Videos for some Chapter 10 examples have been added.
  • March 2009: Added pictures of the PIC24 CPU board and modular logic trainer used at McMaster University to the book adopters page.
  • Feb 2009: Videos for some Chapter 9 examples have been added.
  • Feb 2009: Videos for some Chapter 8 examples have been added.
  • Feb 2009: Updated the code archive with new ADC+DMA examples (chap11/)
  • Feb 2009: Updated the video tutorials page to include a PICkit2 programmer tutorial and a demonstration of the Mini-bully PIC24 breakout board from Sparkfun.
  • The PIC24 textbook is now available in bookstores and at Amazon.com
  • January 26, 2009 - Code archive updated to add more examples converted to the Explorer16 board.
  • December 1, 2008 - Code archive updated, errata in include/pic24_comparator.h fixed.
  • November 23, 2008 - Bully Bootloader GUI updated to version 0.20 to fix an error with program verification after programming and configuration bit programming. Please update your version from the code archive.

Google Groups
PIC24 Assembly-to-C Book
Visit this group

 Other links