ljbeng
Joined: 10 Feb 2004 Posts: 205
|
Bootloader PCD for PIC24FJ128GA006 |
Posted: Wed Nov 04, 2009 5:29 pm |
|
|
I have the Ex_pcd_bootloader and bootload programs compiled for my chip (the demo board that came with compiler).
I made the following mods to each:
Code: |
#if defined PIC24FJ
#include <24FJ128GA006.h>
#fuses HS,NOWDT,NODEBUG,PR, NOWRT, NOPROTECT
#define PUSH_BUTTON PIN_f6
//#pin_select U2TX = PIN_C9
//#pin_select U2RX = PIN_C3
#device adc=8
#use delay(clock=2000000)
#use rs232(baud=9600, UART1)
#endif
|
I use the ICD to download ex_pcd_bootloader, it runs and I see the "Bootloader Program" message in SIOW. I then compile the Ex_pcd_bootload program with the same mod as above. I reset the board and hold the button down and SIOW shows the bootloader messages correctly. I then do a software download and the little window pops up and sends the program until it gets almost done, then freezes and I get a "timeout while downloading" message. I abort that and the PIC resets and I now see the message from ex_pcd_bootload. Now I cannot bootload again. When I reset and hold the button down, I get no messages until I let go of the button and then I get the "you can put whatever code..." message from ex_pcd_bootload. It almost works, just not all there. What else should I look for? Thanks.
Code: |
#define PIC24FJ
//#define PIC24HJ
//This define controls whether or not the bootloader is included in the
//final hex file for programming.(Defined=yes, commented out = no)
//#define _bootloader
#define __PCD__
#if defined PIC24FJ
#include <24FJ128GA006.h>
#fuses HS,NOWDT,NODEBUG,PR, NOWRT, NOPROTECT
#define PUSH_BUTTON PIN_f6
//#pin_select U2TX = PIN_C9
//#pin_select U2RX = PIN_C3
#device adc=8
#use delay(clock=20000000)
#use rs232(baud=9600, UART1)
#endif
//This is a neccessary include file. It reserves space so that the
//bootloader is not overwritten.
#include "pcd_bootloader.h"
#org default
void main(void)
{
setup_adc_ports(NO_ANALOGS);
//setup_adc_ports2(NO_ANALOGS); //33FJ128GP706 only
delay_ms(100);
//On powerup, if the designated button/pin is held low, the program
//will jump to the bootloader, allowing for serial programming.
if(!input(PUSH_BUTTON))
{
#asm
goto LOADER_ADDR
#endasm
}
printf("You can put whatever code you want here.\r\n");
printf("So enjoy!\r\n");
while(1);
} |
|
|