Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Bootloader

Status
Not open for further replies.
For there VB Application edit the RUN code to:

Code:
        Case "Run"
            
            MyButtons = MsgBox("Disabling the bootloader will lock out boot mode. Be sure to have re-entry" & vbCrLf & "code within your firmware to use the bootloader in the future." & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Disable Bootloader...")
            If MyButtons = vbNo Then   ' User chose Yes.
                Exit Sub   ' Perform some action.
            End If
            
            'GotoRunMode
            ReDim InData(10) As Byte
            
            InData(0) = 9
            InData(1) = 1
            SendGetPacket PicBootS.PortHandle, InData(0), 2, 255, 3
            
            DisconnectDev
            StatusBar1.Panels(PANEL_STATUS).Text = STATUS_RUNMODE_SET
 
This sucks it programs ok and even works with other precompiled hexes which was made for a bootloader. But doesnt work with my own code lol

Code:
	#include <P18F2525.INC>	;processor specific variable definitions

		CBLOCK	0x080
		d1
		d2
		d3
		ENDC

		ORG	0x200
		bra	Main		;go to start of main code

		ORG	0x0208
		bra	HighInt		;go to high priority interrupt routine

		ORG	0x0218
		retfie

HighInt:
		retfie	FAST

;******************************************************************************
;Start of main program
; The main program code is placed here.

Main:
	movlw	0x0F
	movwf	ADCON1
	CLRF	TRISB
Loop:
	bcf		LATB,1
	call	Delay
	bsf		LATB,1
	call	Delay
	goto	Loop

Delay
	movlw	0x07
	movwf	d1
	movlw	0x2F
	movwf	d2
	movlw	0x03
	movwf	d3
Delay_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	$+6
	decfsz	d3, f
	goto	Delay_0
	goto	$+2
	goto	$+2
	goto	$+2
	return

		END

heh had a delay code error only lol everything works now :D
 
Last edited:
Maybe you recall this from earlier. If so ignore.

The bootloader takes up the first few K of memory so the program code has to start after that. The linker script you use without a boot loader will not work with a boot loader.
 
I got it working in ASM no problem now C is killing me lol. I edited the "c018i.c": (after editing this file i recompiled it with the BATCH file included in MCC18)
FROM:
Code:
#pragma code _entry_scn=0x000000
void
_entry (void)
{
_asm goto _startup _endasm

}
TO:
Code:
#pragma code _entry_scn=0x000200
void
_entry (void)
{
_asm goto _startup _endasm

}

I edited the linker:
Code:
// $Id: 18f2525.lkr,v 1.3 2004/04/26 18:02:17 curtiss Exp $
// File: 18f2525.lkr
// Sample linker script for the PIC18F2525 processor

LIBPATH .

FILES c018i.o
FILES clib.lib
FILES p18f2525.lib

//CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
//CODEPAGE   NAME=page       START=0x2A           END=0xBFFF

CODEPAGE   NAME=boot       START=0x0            END=0x1FF          PROTECTED
CODEPAGE   NAME=vectors    START=0x200          END=0x229          PROTECTED
CODEPAGE   NAME=page       START=0x22A          END=0xBFFF
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=0xF003FF       PROTECTED

ACCESSBANK NAME=accessram  START=0x0            END=0x7F
DATABANK   NAME=gpr0       START=0x80           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=gpr4       START=0x400          END=0x4FF
DATABANK   NAME=gpr5       START=0x500          END=0x5FF
DATABANK   NAME=gpr6       START=0x600          END=0x6FF
DATABANK   NAME=gpr7       START=0x700          END=0x7FF
DATABANK   NAME=gpr8       START=0x800          END=0x8FF
DATABANK   NAME=gpr9       START=0x900          END=0x9FF
DATABANK   NAME=gpr10      START=0xA00          END=0xAFF
DATABANK   NAME=gpr11      START=0xB00          END=0xBFF
DATABANK   NAME=gpr12      START=0xC00          END=0xCFF
DATABANK   NAME=gpr13      START=0xD00          END=0xDFF
DATABANK   NAME=gpr14      START=0xE00          END=0xEFF
DATABANK   NAME=gpr15      START=0xF00          END=0xF7F
ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED

SECTION    NAME=CONFIG     ROM=config

STACK SIZE=0x100 RAM=gpr10

This is my C18 main code:
Code:
#include <p18f2525.h>
#include <delays.h>

void main(void){


    TRISB = 0x00;

	while(1){
        LATBbits.LATB1 = 0;
        Delay1KTCYx(200);
        LATBbits.LATB1 = 1;
        Delay1KTCYx(200);        
	}
}

I kept it short and simple since the OSC is already set from bootloader even if not used.
 
Status
Not open for further replies.

Latest threads

Back
Top