Quote Originally Posted by Bruce View Post
All of the HID loader loader firmware is available. Just start MPLAB, open the HID loader
project, select MPSIM as the debugger, then select View Program Memory.

As you step through the loader source you can view where it checks for RB4, and jumps
into the loader section if RB4=0.

In the C source it's if(sw2 == 1) then run user program. If (sw2 == 0), it jumps to the
loader section.

An easy way would be to have your own code test RB4, and issue an assembler RESET
instruction if RB4=0.

Or you can step through the C18 source and find the exact location to GOTO & land right
on the loader routine start section.
Bruce, thanks for the excellent idea.
The only problem seems to be that I have only PICbasicPro but not PIC C-compailer. It seems to me that you can not use MPLAB to run a source code if you do not have a corresponding compiler (in this case C-compiler).

What we know at this point is that the decision is made on RB4.
Using MPLAB and choosing first Program Memory and when that is open you choose Machine or Symbolic tab at the bottom of the page and you can then see the disassembled listing.

You cannot find RB4, however you can find PORTB, and in this HID bootloader only in one place, line 1953 and the disassembled code looks like this there:

Line, Address, Opcode, Disassembly
1953 0F40 A881 BTFSS, PORTB, 0x4, ACCESS
1954 0F42 D004 BRA 0xf4c
1955 0F44 0E07 MOVLW 0x7
1956 0F46 6EC1 MOVWF ADCON1, ACCESS
1957 0F48 EF00 GOTO 0x1000
1958 0F4A F008 NOP
1959 0F4C D80E RCALL 0xf6a

So, a jump from the application code to 0x0f4a (NOP) or 0xf4c (RCALL oxf6a) should work, at least one would think so and "the problem" is hence solved. I will tell you if there are other problems... hope not

The ACCESS on line 1953 and line 1956 refers to access bank? Is this true? Could one find a good PIC18F4550/2550 tutorial on the web somewhere, where all about the assembler would be clearly explained?

Thanks again Bruce for your great support...