THE DESIGN CYCLE
■ SCHEMATIC 1. Stay
tuned! We’re going
to have some who’s-behind-the-mask
Mardi Gras fun with
the main components
in this schematic.
the privilege to carve out some configuration definition space
of our own within the confines of HardwareProfile.h:
#elif defined(ZeroG_PIC24FJ128GA006_TRAINER)
// Define your own board hardware profile here
// PIC24F processor
#define GetSystemClock() (32000000ul) // Hz
#define GetInstructionClock()
(GetSystemClock()/2)
#define GetPeripheralClock()
GetInstructionClock()
#define LED0_TRIS
#define LED0_IO
#define LED1_TRIS
#define LED1_IO
// no other LED’s
#define LED3_TRIS
#define LED3_IO
#define LED4_TRIS
#define LED4_IO
#define LED5_TRIS
#define LED5_IO
#define LED6_TRIS
#define LED6_IO
#define LED7_TRIS
#define LED7_IO
#define LED_GET()
#define LED_PUT(a)
(TRISCbits.TRISC13)
(LATCbits.LATC13)
(TRISCbits.TRISC14)
(LATCbits.LATC14)
LED1_TRIS
LED1_IO
LED1_TRIS
LED1_IO
LED1_TRIS
LED1_IO
LED1_TRIS
LED1_IO
LED1_TRIS
LED1_IO
(*((volatile unsigned
int*)(&LATC)))
(*((volatile unsigned
int*)(&LATC)) = (a))
The pair of user LEDs and the clocking scheme are
exposed to the rest of the stack components in our ZeroG
Trainer HardwareProfile.h definition space. Note that since
we only have a pair of LEDs and the Stack is expecting to
see a few more, we must dummy up on nonexistent LEDs
that may be expected to be there by other modules that
comprise the TCP/IP Stack. Our definition coding references
any calls to nonexistent LEDs to our LED1. Any LED
beyond LED1 that is referenced in the Stack will resolve to
LED1. The absence of the LEDs beyond LED1 won’t keep
the Stack from functioning. However, trust me. You will
grow weary of fixing the undefined LED compile errors.
Our MainDemo.c application file wants to blink LED0 to
let us humans know that the Stack code is running:
// Blink LED0 (right most one) every second.
if(TickGet() - t >= TICK_SECOND/2ul)
{
t = TickGet();
LED0_IO ^= 1;
}
The Stack creators have thrown us a bone here with
the gift of the LED_GET and LED_PUT macros.
■ FIGURE 1. This is a graphic depiction of the ZeroG -
PIC24FJ128GA006 Trainer ExpressPCB layout file. You can
get the actual ExpressPCB file from within this month’s
download package at www.nutsvolts.com.
May 2010 55