Posts Tagged “UART”

This fix refers to the library version release 12 April 2011. When using an Explorer 16 board and setting the Macro definition of EXPLORER16_100P in MPLab, parts of the library do not pick it up correctly rendering the heartbeat LED and the UART to not work. No compilor error is noticed.

In the file lib\include\pic24_libconfig.h at line 76, change the following section of code:

/** Select one of the hardware platform above to compile for. */
#ifndef HARDWARE_PLATFORM
#define HARDWARE_PLATFORM DEFAULT_DESIGN
#endif
// Verify that a valid hardware platform is selectd
#if (HARDWARE_PLATFORM != EXPLORER16_100P)   && \
    (HARDWARE_PLATFORM != DANGEROUS_WEB)     && \
    (HARDWARE_PLATFORM != STARTER_BOARD_28P) && \
    (HARDWARE_PLATFORM != DEFAULT_DESIGN)
#error Invalid hardware platform selected.
#endif
//@}

Replacing the above code with this code:

/** Select one of the hardware platform above to compile for. */
/* The automated method expects the board is defined in MPLAB
   using Use Project->Build Options-> Project, click on
   the MPLAB C30 tab, and in Macro Definitions click 'Add',
   and add:
      - For the Explorer 16 board - EXPLORER16_100P
      - For the Dangerous Prototypes web server - DANGEROUS_WEB
      - For the Microchip 16-bit 28-pin Starter Board - STARTER_BOARD_28P
   If the above is not set, the code will compile with the default
   of DEFAULT_DESIGN
*/
#ifndef HARDWARE_PLATFORM
#ifdef EXPLORER16_100P
#define HARDWARE_PLATFORM EXPLORER16_100P
#elif STARTER_BOARD_28P
#define HARDWARE_PLATFORM STARTER_BOARD_28P
#elif DANGEROUS_WEB
#define HARDWARE_PLATFORM DANGEROUS_WEB
#else
#define HARDWARE_PLATFORM DEFAULT_DESIGN
#endif
#endif
// Verify that a valid hardware platform is selectd
#if (HARDWARE_PLATFORM != EXPLORER16_100P)   && \
    (HARDWARE_PLATFORM != DANGEROUS_WEB)     && \
    (HARDWARE_PLATFORM != STARTER_BOARD_28P) && \
    (HARDWARE_PLATFORM != DEFAULT_DESIGN)
#error Invalid hardware platform selected.
#endif
//@}

This will now pick up the Macro definition set in MPLab and compile the components of the library needed for the Explorer 16 to function.

So far have tested the above with the Explorer 16, PIC24HJ256GP610A PIM, and the reset.c example from chapter 8 in the Microcontrollers: From Assembly Language to C Using the PIC24 Family.

Comments No Comments »

The UART example on page 262 just needs the Explorer16 check list from the last article to make it work and the ASM example I skipped as it’s not needed at this stage of my journey.

The file name for the Figure 8.6 example is documented in the book. Well done to the author and publisher :) It’s called ‘echo’ for those that might have missed it.

Comments No Comments »