Hola a todos! Estoy con problemas hace varios dias tratando de hacer andar el bootloader con usb(pic18f46j50). Estoy trabajando con el ejemplo ex_usb_bootloader que viene en el compilador, grabo con el programador el bootloader en el pic y carga perfectamente el programa usando siow, pero el programa no corre!. Ya lo revise miles de veces y no encuentro donde esta el problema, creo que deberia estar en usb_bootloader.h, revise las posiciones de memorias,fusibles(no los modifica el bootloader),etc.Ayuda por favor!
Este es el programita de testeo que cargo desde siow(prende y apaga un led)
#include <18F46J50.h>
#fuses INTRC_PLL_IO, PLL2,NOPROTECT,NODEBUG,NOCPUDIV,NODSBOR,NODSWDT,NOWPFP,NOWPCFG,NOWPDIS,NOFCMEN,NOIESO,RTCOSC_T1,WDT,WDT32768
#use delay(clock=48mhz)
#include <usb_bootloader.h>
#DEFINE LEDAMA PIN_B3
void main() {
setup_oscillator(OSC_PLL_ON);
setup_adc (ADC_OFF);
setup_comparator (NC_NC_NC_NC);
SETUP_WDT (WDT_OFF);
port_b_pullups (FALSE);
output_LOW(LEDAMA);
DELAY_MS(100);
while(true){
output_HIGH(LEDAMA);
DELAY_MS(500);
output_LOW(LEDAMA);
DELAY_MS(500);
}
}
Este es el archivo usb_bootloader.h
#define LOADER_SIZE (0x1FFF)
//#else
//#define LOADER_SIZE (0x17FF)
//#endif
//the loader and application need a common flag that determines if we are in
//the bootloader or application, that way the ISR knows where to go. this
//is the location in ram that is reserved for this flag.
#define LOC_IN_LOADER_FLAG 0x25
//// --- end configuration --- ////////////////////////////////////////////
#reserve LOC_IN_LOADER_FLAG
int8 g_InBootloader;
#locate g_InBootloader=LOC_IN_LOADER_FLAG
#define LOADER_START (0)
#define LOADER_END (LOADER_SIZE)
#define APPLICATION_START (LOADER_SIZE+1)
#if defined(__USB_87J50__)
#define APPLICATION_END (getenv("PROGRAM_MEMORY")-9) //configuration bits
#else
#define APPLICATION_END (getenv("PROGRAM_MEMORY")-1)
#endif
#define APPLICATION_ISR (APPLICATION_START+8)
#ifdef _bootloader
/*
Provide an empty application, so if you load this .HEX file into the pic
without an application this will prevent the pic from executing unknown code.
*/
#org APPLICATION_START,APPLICATION_START+0xF
void BlankApplication(void)
{
while(TRUE);
}
//we need to prevent the loader from using application space
#if (APPLICATION_END > 0x10000)
#org APPLICATION_START+0x10, 0xFFFF {}
#if (APPLICATION_END > 0x20000)
#org 0x10000, 0x1FFFF {}
#org 0x20000, APPLICATION_END {}
#else
#org 0x10000, APPLICATION_END {}
#endif
#else
#org APPLICATION_START+0x10, APPLICATION_END {}
#endif
// #define USB_CONFIG_PID 0x0034
#define USB_CONFIG_PID 0x0033
#define USB_STRINGS_OVERWRITTEN
char USB_STRING_DESC_OFFSET[]={0,4,12};
// Here is where the "CCS" Manufacturer string and "SERIAL DEMO" are stored.
// Strings are saved as unicode.
// These strings are mostly only displayed during the add hardware wizard.
// Once the operating system drivers have been installed it will usually display
// the name from the drivers .INF.
char const USB_STRING_DESC[]={
//string 0
4, //length of string index
0x03, //USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
0x09,0x04, //Microsoft Defined for US-English
//string 1 - manufacturer
8, //length of string index
0x03, //USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'C',0,
'C',0,
'S',0,
//string 2 - product
30, //length of string index
0x03, //USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'C',0,
'D',0,
'C',0,
' ',0,
'B',0,
'o',0,
'o',0,
't',0,
'l',0,
'o',0,
'a',0,
'd',0,
'e',0,
'r',0
};
#endif //_bootloader
#ifndef _bootloader
//in the application, this moves the reset and isr vector out of the bootload
//space. it then reserves the loader space from being used by the application.
#build(reset=APPLICATION_START, interrupt=APPLICATION_ISR)
#org 0, LOADER_END {}
#endif