Work on PIC18LF2455, first using PICkit 2 to flash bootloader to PIC18LF2455.
RB5 - Push Button (Enter Bootloader Mode)
RC0 - Busy LED
//PICkit User Guide
PK2Error0018: Unable to enter bootloader
Description: PICkit 2 Debug Express was unable to access the PICkit 2 unit bootloader
while updating the PICkit 2 Operating System.
Suggested Actions: Disconnect the PICkit 2 unit from USB and the target board. While
holding the PICkit 2 unit push button down, plug the PICkit 2 unit back into the USB
port. The BUSY LED should flash slowly. If it does not, the bootloader may be
corrupted. Contact Microchip about the problem.
//******************
see boot.h for memory maps for remapped vectors
#define RM_RESET_VECTOR 0x002000
#define RM_HIGH_INTERRUPT_VECTOR 0x002008
#define RM_LOW_INTERRUPT_VECTOR 0x002018
-------------------------------
// Write key 0x5555 at last memory location to tell bootloader FW loaded.
if (!Pk2.BL_WriteFWLoadedKey())
{
displayStatusWindow.Text = "Error loading Operating System.";
displayStatusWindow.BackColor = Color.Salmon;
return;
}
---------------------------------
public static bool BL_WriteFWLoadedKey()
{
byte[] flashWriteData = new byte[3 + 32]; // 3 address bytes plus 32 data bytes.
flashWriteData[0] = 0xE0;
flashWriteData[1] = 0x7F;
flashWriteData[2] = 0x00; // Address = 0x007FE0
for (int i = 3; i < flashWriteData.Length; i++)
{
flashWriteData[i] = 0xFF;
}
flashWriteData[flashWriteData.Length - 2] = 0x55;
flashWriteData[flashWriteData.Length - 1] = 0x55;
return BL_WriteFlash(flashWriteData);
}
----------------------------------------
// boot_main.c
if (PROG_SWITCH) { // is the push button pressed?
// if no, does program memory location 0x7FFE contain 0x55?
Temp = * ((rom far char *) 0x7FFE);
if(Temp == 0x55) {
_asm goto RM_RESET_VECTOR _endasm
}
} // end if (PROG_SWITCH)
// disassembly
Line Address Opcode Label DisAssy 1845 0E68 AA81 BTFSS PORTB, 5, ACCESS
1846 0E6A D00D BRA 0xE86
1847 0E6C 0EFE MOVLW 0xFE
1848 0E6E 6EF6 MOVWF TBLPTRL, ACCESS
1849 0E70 0E7F MOVLW 0x7F
1850 0E72 6EF7 MOVWF TBLPTRH, ACCESS
1851 0E74 6AF8 CLRF TBLPTRU, ACCESS
1852 0E76 0008 TBLRD*
1853 0E78 50F5 MOVF TABLAT, W, ACCESS
1854 0E7A 6EDF MOVWF INDF2, ACCESS
1855 0E7C 0E55 MOVLW 0x55
1856 0E7E 5CDF SUBWF INDF2, W, ACCESS
1857 0E80 E102 BNZ 0xE86
1858 0E82 EF00 GOTO 0x2000
1859 0E84 F010 NOP
// HEX file
:100E70007F0EF76EF86A0800F550DF6E550EDF5CE6
change 7F to 5F for 24Kbyte device, 5FFF(24K device), 7FFF(32K device) end of on-chip program memory. E6 is the checksum
to
:100E70005F0EF76EF86A0800F550DF6E550EDF5C06
>PIC18F2550
:100D400000430031003800460032003500350030E5
>PIC18F2455
:100D400000430031003800460032003400350035E1
// user program can start from address 1000
--------------------
Program Linker Options
Memory Model:: ROM Ranges: default,-5FF0-5FFF
Additional Options:: Codeoffset: 0x2000
--------------------
PIC18LF25k50 Vusb3v3 tied to Vdd (no internal 3.3V LDO regulator)
PIC18F25k50 Vusb3v3 tied to capacitor (using internal 3.3V LDO regulator)
--------------------
VDD ranges are different for PIC18LF25K50 and PIC18LF2550
notes: PIC18LF25K50 is like PIC18F2550, PIC18F25K50 is like PIC18LF2550.
-------------------
No comments:
Post a Comment