Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] PIC18F27J53 Bootloader Mode Issues

Status
Not open for further replies.

junkie_

Junior Member level 2
Joined
Oct 9, 2005
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,476
I have downloaded and compiled Microchip Bootloader for PIC18F27J53 found in Microchip Solutions v2010-08-04, the original code found in the directory has bootloader mode button located at RB2, I tried to move it to RB5 instead, I think I did change the code, however, when I compile and burn the bootloade in the PIC the PIC is now not entering the bootloader loader, would some point out the mistake I am doing.

Here is the original code
Code:
_entry (void)
{
	_asm
	movlb	0x0F				//Address: 0x00		//Will be checking RB2 pushbutton state, but need to set ANCON1<PCFG8> bit first. ANCON1 register is not in access bank
	bsf		ANCON1, 0, 1		//Address: 0x02		//Configure RB2/AN8 as digital input
	bra		BootEntryIOCheck	//Address: 0x04		//bra BootEntryIOCheck skips past the high-priority interrupt redirect
	nop							//Address: 0x06		//Filler to waste 2 byte of program memory

	//HIGH PRIORITY INTRRUPT VECTOR at address 0x08
    goto 0x1008					//Address: 0x08		//If a high priority interrupt occurs, PC first goes to 0x0008, then executes "goto 0x1008" redirect

BootEntryIOCheck:
	//Perform an I/O pin check to see if we should enter either the main application firmware, or this bootloader firmware.
	//Currently using RB2 I/O pin for this purpose.  If pushbutton pressed (RB2 = 0), enter bootloader firmware.
	//If not pressed (RB2 = 1, due to pull up resistor), enter the main application firmware instead.
    btfss	PORTB, 2, 0			//Address: 0x0C		//Check RB2 I/O pin state	
    bra		BootAppStart		//Address: 0x0E		//If pushbutton pressed, enter bootloader	

	//Otherwise, need to enter the main application firmware.
	//Should restore state of BSR and ANCON1 registers to default state first.
	bcf		ANCON1, 0, 1		//Address: 0x10		//Restore ANCON1<PCFG8> bit to default
	movlb	0x00				//Address: 0x12		//Restore BSR to POR default
    goto	0x1000				//Address: 0x14		//Goto the main application firmware, user was not pressing the pushbutton to enter bootloader
    
	//LOW PRIORITY INTERRUPT VECTOR at address 0x18    
    goto	0x1018				//Address: 0x18		//If a low-priority interrupt occurs, PC first goes to 0x0018, then executes "goto 0x1018" redirect
	_endasm

BootAppStart:					//Address: 0x1C		//If executing the main application firmware, and user wishes to enter the bootloader
    												//simply execute an "_asm goto 0x001C _endasm" instruction.  This will go to this BootAppStart section,
    												//which in turn will enter the bootloader firmware.
	Main();
}

and I modified the code to the following:

Code:
_entry (void)
{
	_asm
	movlb	0x0F				//Address: 0x00		//Will be checking RB2 pushbutton state, but need to set ANCON1<PCFG8> bit first. ANCON1 register is not in access bank
	bsf		ANCON1, 0, 1		//Address: 0x02		//Configure RB2/AN8 as digital input
	bra		BootEntryIOCheck	//Address: 0x04		//bra BootEntryIOCheck skips past the high-priority interrupt redirect
	nop							//Address: 0x06		//Filler to waste 2 byte of program memory

	//HIGH PRIORITY INTRRUPT VECTOR at address 0x08
    goto 0x1008					//Address: 0x08		//If a high priority interrupt occurs, PC first goes to 0x0008, then executes "goto 0x1008" redirect

BootEntryIOCheck:
	//Perform an I/O pin check to see if we should enter either the main application firmware, or this bootloader firmware.
	//Currently using RB2 I/O pin for this purpose.  If pushbutton pressed (RB2 = 0), enter bootloader firmware.
	//If not pressed (RB2 = 1, due to pull up resistor), enter the main application firmware instead.
    btfss	PORTB, 5, 0			//Address: 0x0C		//Check RB2 I/O pin state	
    bra		BootAppStart		//Address: 0x0E		//If pushbutton pressed, enter bootloader	

	//Otherwise, need to enter the main application firmware.
	//Should restore state of BSR and ANCON1 registers to default state first.
	bcf		ANCON1, 0, 1		//Address: 0x10		//Restore ANCON1<PCFG8> bit to default
	movlb	0x00				//Address: 0x12		//Restore BSR to POR default
    goto	0x1000				//Address: 0x14		//Goto the main application firmware, user was not pressing the pushbutton to enter bootloader
    
	//LOW PRIORITY INTERRUPT VECTOR at address 0x18    
    goto	0x1018				//Address: 0x18		//If a low-priority interrupt occurs, PC first goes to 0x0018, then executes "goto 0x1018" redirect
	_endasm

BootAppStart:					//Address: 0x1C		//If executing the main application firmware, and user wishes to enter the bootloader
    												//simply execute an "_asm goto 0x001C _endasm" instruction.  This will go to this BootAppStart section,
    												//which in turn will enter the bootloader firmware.
	Main();
}
 

Wp100 Hi:

I wish I was good at assembly, I just beginning again after many years with C only.

I changed the code here
Code:
 btfss	PORTB, 5, 0

This was the original code

Code:
btfss	PORTB, 2, 0

Now would any one point where to set PORTB5 as digital input instead of PORTB2
 

Wp100 Hi:

I wish I was good at assembly, I just beginning again after many years with C only.

I changed the code here
Code:
 btfss	PORTB, 5, 0

This was the original code

Code:
btfss	PORTB, 2, 0

Now would any one point where to set PORTB5 as digital input instead of PORTB2


Hi,

PortB should be set to Input by power on default and as RB5 is does not have an Analogue option it should be Digital Input

In case things are changed elsewhere just first set that pin by ' BSF TRISB,5 ,0 ' to ensure it is Input
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top