PDA

View Full Version : Bootloader



Andre_Pretorius
- 6th January 2009, 18:27
Can someone please help me i am trying to get a boot loader working(first timer) i use the microchip loader for the 18F4550 over USB

The problem is that everything works the first time but when i open my hex file the loader comes up with a message that the config differs from the board, if i choose to use the board everything keeps on working but when i use the config from the hx file it seems to overite something in the bootloader code. after the chip resets the program works but i can't go back into bootloader mode. here is my code anyone got any ideas?



INCLUDE "MODEDEFS.BAS"

DEFINE LOADER_USED 1
DEFINE RESET_ORG 1000h ' For Microchip USB Bootloader

DEFINE OSC 20 ' Define crystal as 20Mhz

'Define ACDIN parameters
Define ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source ( 3 = RC )
DEFINE ADC_SAMPLEUS 50 ' Set sampling time to micro-seconds

'This Part set PORTA 0-3 an analog inputs,4 as digital
TRISA = %00011111 'set PORTA 0-5 as inputs
ADCON1 = %00001010 'ADC use vss and vdd as ref.
ADCON2 = %10000111 'FRC (clock derived from A/D RC oscillator),Right justify output

TRISC = %10000000
TRISD = %00001111 'Set port d 0-3 as inputs and 4-7 as outputs
TRISB = %10011000

'**************************************Serial port setup*************************************
'*Serial port Setup 9600 8N1*
DEFINE HSER_BAUD 9600 ; 9600 Baud
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_CLROERR 1 ; Clear overflow automatically
DEFINE HSER_SPBRG 129

'**************************************Variables** *******************************************
buffer Var Byte[16]
cnt Var Byte
LED Var PORTD.4


USBInit
Low LED ' LED off

'**************************************Main Program******************************************

idleloop:
PORTD.7 = 1
PAUSE 1000
PORTD.7 = 0
PAUSE 1000


Goto idleloop ' Wait for next buffer


END

Bruce
- 6th January 2009, 20:53
The Microchip USB loader expects the CPU core to be running at 48MHz. Just change your
DEFINE OSC to 48, and accept the default config settings - unless you know enough to
modify the USB C loader firmware to operate at a different oscillator speed.

Andre_Pretorius
- 17th January 2009, 06:18
Hi there i have changed my cristal to a 48M but now my bootloader does not work, after mor reading on this forum i came to another link saying the bootloader works on 20M
http://www.picbasic.co.uk/forum/showthread.php?t=5590
if i go back to a 20M everything seems to work the problem seemed to be that the config in the include file (18f4550.inc) and in the microchip main.c needs to be the same.

Now i have another question since i have 48M cristals how do you convert the bootloader to work on 48M??:cool:

Andre_Pretorius
- 17th January 2009, 08:00
I know this is not the c forum but mabe someone can help this is the config i have in the main.c file of the bootloader is this correct and is there other places i have to edit to get it working my PC keeps on poping up with unregognised device


#if defined(PIC18F4550_PICDEM_FS_USB) // Configuration bits for PICDEM FS USB Demo Board
#pragma config PLLDIV = 12 // (48 MHz crystal on PICDEM FS USB board)
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2 // Clock source from 96MHz PLL/1
#pragma config FOSC = HSPLL_HS
#pragma config FCMEN = OFF
#pragma config IESO = OFF
#pragma config PWRT = OFF
#pragma config BOR = ON
#pragma config BORV = 3
#pragma config VREGEN = ON //USB Voltage Regulator
#pragma config WDT = OFF
#pragma config WDTPS = 32768
#pragma config MCLRE = ON
#pragma config LPT1OSC = OFF
#pragma config PBADEN = OFF