The Demonstration Application
©
2009 Microchip Technology Inc.
DS51852A-page 11
FIGURE 2-3:
PROGRAM MEMORY MAP OF THE PIC18F46J50 DEMO
2.1.3
Writing Application Code
The bootloader operates as a separate entity, which means that an application can be
developed with very little concern about what the bootloader is doing.
When using the MPLAB
®
C18 C compiler to develop PIC18F firmware for an application,
the linker file must be changed to protect the program memory used by the bootloader
and the interrupt handler must be updated with the new vectors.
An example linker file
(
18f46j50_g.lkr
) is provided on the starter kit CD-ROM.
If the need exists to re-enter the bootloader from the application (and it usually does), it
will be necessary to monitor the state of the S1 switch periodically. Since the bootloader
assumes Reset conditions, a
RESET
instruction should be initiated if the S1 is pressed.
An example stub application
(
USB Device-HID-Mouse\Firmware\mouse.c
)
on the
starter kit CD demonstrates how to re-enter the bootloader from the main application.
2.2
USB HID MOUSE DEMO
This demo uses the starter kit as a USB mouse. When the application is run, the starter
kit functions like any other mouse under the Windows operating system.
The movement of the mouse cursor on the X and Y axes is controlled using the
on-board accelerometer. The acceleration on all three axes is used to compute the
board tilt, which is then converted to movement of the mouse cursor on the X and Y
axis. This conversion is not linear, allowing for slow movement of the cursor when the
board is tilted a small amount, and fast movement for a steeper tilt. Keeping the board
level (with respect to the ground) stops all cursor motion.
The touch pads are used for the
Left
and
Right
mouse buttons, while the scroll bar is
used for the mouse scroll wheel.
Bootloader
Firmware
Reset Vector
High-Priority Interrupt
Vector
Low-Priority Interrupt
Vector
Application
Program Memory
A000h
A008h
A018h
FFFFh
Use
r Me
mo
ry
S
p
a
c
e
Note:
Memory areas are not shown to scale.
0000h
Summary of Contents for MPLAB
Page 1: ...2009 Microchip Technology Inc DS51852A MPLAB Starter Kit for PIC18F User s Guide...
Page 4: ...MPLAB Starter Kit for PIC18F User s Guide DS51852A page iv 2009 Microchip Technology Inc NOTES...
Page 10: ...MPLAB Starter Kit for PIC18F User s Guide DS51852A page 6 2009 Microchip Technology Inc NOTES...
Page 32: ...MPLAB Starter Kit for PIC18F User s Guide DS51852A page 28 2009 Microchip Technology Inc NOTES...
Page 42: ...MPLAB Starter Kit for PIC18F User s Guide DS51852A page 38 2009 Microchip Technology Inc NOTES...
Page 45: ...Index 2009 Microchip Technology Inc DS51852A page 41 NOTES...