Programming the Dwengo board without a programmer
Installing the bootloader
Programming the bootloader on the Dwengo board can be done easily. For this you first download the hex file Dwengo bootloader that is attached to this page. This hex file contains the bootloader for the Dwengo board. With MPLAB you can program the Dwengo board with this hex file. The bootloader will now take the first 8192 bytes (0x0000 - 0x1FFF) of the program memory.
Writing a program
Since the bootloader takes the first 8192 bytes (0x0000-0x1FFF) of program memory, you have to take two things into account when writing your own programs: remapping the interrupt vectors and adjusting the linker script.
Remapping the interrupt routines is done with the following code:
void YourHighPriorityISRCode(); void YourLowPriorityISRCode(); // vector remapping // Bootloader occupies addresses 0x000-0x1FFF and thus cannot be used. // Thus adresses 0x00, 0x08 and 0x18 (used for reset, high prior interrupt, // and low prior interrupt) have to be remapped. extern void _startup(void); #pragma code REMAPPED_RESET_VECTOR = 0x2000 void _reset(void) { _asm goto _startup _endasm } #pragma code REMAPPED_HIGH_INTERRUPT_VECTOR = 0x2008 void Remapped_High_ISR(void) { _asm goto YourHighPriorityISRCode _endasm } #pragma code REMAPPED_LOW_INTERRUPT_VECTOR = 0x2018 void Remapped_Low_ISR (void) { _asm goto YourLowPriorityISRCode _endasm } #pragma code HIGH_INTERRUPT_VECTOR = 0x08 void High_ISR(void) { _asm goto 0x2008 _endasm } #pragma code LOW_INTERRUPT_VECTOR = 0x18 void Low_ISR(void) { _asm goto 0x2018 _endasm } #pragma code // Interrupt handler routines #pragma interrupt YourHighPriorityISRCode void YourHighPriorityISRCode() { //Check which interrupt flag caused the interrupt //Service the interrupt //Clear the interrupt flag } #pragma interruptlow YourLowPriorityISRCode void YourLowPriorityISRCode() { // Check which interrupt flag caused the interrupt // Service the interrupt // Clear the interrupt flag }
The linker script has to be adjusted in such a way the a piece of the program memory is reserved for the bootloader. Moreover, there also needs to be reserved a piece of memory for the interrupt vectors. The following lines describe a working linker script that can be used with the bootloader:
LIBPATH . FILES c018i.o FILES clib.lib FILES p18f4550.lib CODEPAGE NAME=bootloader START=0x0 END=0x1FFF PROTECTED CODEPAGE NAME=vectors START=0x2000 END=0x2029 PROTECTED CODEPAGE NAME=page START=0x202A END=0x7FFF CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED CODEPAGE NAME=eedata START=0xF00000 END=0xF000FF PROTECTED ACCESSBANK NAME=accessram START=0x0 END=0x5F DATABANK NAME=gpr0 START=0x60 END=0xFF DATABANK NAME=gpr1 START=0x100 END=0x1FF DATABANK NAME=gpr2 START=0x200 END=0x2FF DATABANK NAME=gpr3 START=0x300 END=0x3FF DATABANK NAME=usb4 START=0x400 END=0x4FF PROTECTED DATABANK NAME=usb5 START=0x500 END=0x5FF PROTECTED DATABANK NAME=usb6 START=0x600 END=0x6FF PROTECTED DATABANK NAME=usb7 START=0x700 END=0x7FF PROTECTED ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED SECTION NAME=CONFIG ROM=config STACK SIZE=0x100 RAM=gpr3 SECTION NAME=USB_VARS RAM=usb4
Programming without a programmer
When the program is ready and you have generated a hex file, you can program the Dwengo board. First you have to download the USB framework from the Microchip website
. Install this framework and under C:\Microchip Solutions\USB Device - Bootloaders\HID - Bootloader you can find the program HIDBootLoader.exe. Start this program. If the program does not want to start, you also have to install the Microsoft .NET framework
.
After this connect the Dwengo board to your computer with a USB cable (without the programmer). Next reset the Dwengo board while pressing the C button. When you release the C button, the board is bootloader modus. The Dwengo board will now be detected by the HIDBootLoader program. With this HIDBootLoader program you can load you hex file and program it on the Dwengo board.
- Type:

Your shopping cart