THE DESIGN CYCLE
■ SCHEMATIC 1. The PIC24F/PIC32MX USB Trainer is a base
16-bit design with USB capability. The idea is for you to
flesh out the basic design with your own personal set of
peripherals. Allowing the user to add to the base design
keeps the USB Trainer’s cost down and the usability high.
#ifndef EDTP_PIC24F_PIC32MX_TRAINER
#define EDTP_PIC24F_PIC32MX_TRAINER
Following our grand announcement of the hardware
behind this code, you’ll encounter the bootloader options.
You’ll find the bootloader code unchanged in our version
of the HardwareProfile definitions. However, to inform the
rest of the USB stack modules of our hardware’s presence
we must declare ourselves one more time as to who we
are:
#define EDTP_PIC24F_PIC32MX_TRAINER
#define CLOCK_FREQ 32000000
As you can see, it’s also a good time to tell the rest of
the USB stack the speed of our CPU clock.
The LEDs included in the Trainer design serve a dual
purpose. The status of the USB link enumeration is
displayed in the LEDs. Once the link is up and running in
the CONFIGURED state, the LEDs become part of the
demo application which is part of the main.c file we’ll look
at later. In keeping with Fred Eady’s First Law of
Embedded Computing that “Nothing is free,” to utilize the
LEDs we must configure them in the USB stack’s USB
TRAINER.h file:
/** LED ****************************************/
#define mInitAllLEDs() LATC &= 0x9FFF; TRISC
&= 0x9FFF; //RC13, RC14
#define mLED_1
#define mLED_2
LATCbits.LATC13
LATCbits.LATC14
#define mGetLED_1()
#define mGetLED_2()
mLED_1
mLED_2
#define mLED_1_On()
#define mLED_2_On()
mLED_1 = 1;
mLED_2 = 1;
#define mLED_1_Off()
#define mLED_2_Off()
mLED_1 = 0;
mLED_2 = 0;
#define mLED_1_Toggle() mLED_1 = !mLED_1;
#define mLED_2_Toggle() mLED_2 = !mLED_2;
I chose to keep the USB stack’s original LED definition
names. That makes it easier to get a successful compile as
you don’t have to sift through the stack renaming the
LEDs. As you’ll see later, the main.c application and status
routines will utilize the LED GetLED, On, Off, and Toggle
macros.
The TPS2041BDBVT is not something that the USB
June 2010 61