Tuesday, December 15, 2015

PICkit 2 firmware porting to XC8

--------- Bootloader ---------
1. Create MPLAB X project.
2. Update Compiler Include Path
3. Generate Configuration File
4. Compile each c file
     a. Change typedefs.h
     b. Comment out "pragma udata", "pragma code"
     c. Change _asm to asm()
#pragma psect usbram XX -> using @0x400...

    if (U1IEbits.UERRIE && U1IRbits.UERRIF)
    {
#if defined (DEBUG_ENABLE)
        DEBUG_PutChar('#');
        DEBUG_PutHexUINT8( U1EIR );
#endif

* * * *
porting to XC8 on halt due to unknow USB issues ... try another approach using MLA usb bootloader...

1. Copy Project
2. Change Descriptor Data
3. Change Enter Bootloader Button to RB5 as in PICkit 2
4. Change Command
5. Check BootPICxxx.h and VectorRemap.asm for Vector setup

    #define REMAPPED_APPLICATION_RESET_VECTOR       0x2000
    #define APP_SIGNATURE_ADDRESS                   0x7FFE
    #define APP_SIGNATURE_VALUE                     0x5555


======== PICkit Bootloader / Find PICkit Device==========
1. Send Command 'v', if the return data[1]=0x76, it's the bootloader
    data[6]='B',data[7]=Major_Version,data[8]=Minor_Version

2. Configuration Bits, WRTB, WRT0 is clear for Write Protection from 0x0000~0x1FFF

3.
void ReadVersion(void);   //test OK
void ReadProgMem(void);   //test OK
void WriteProgMem(void);  //test OK
void EraseProgMem(void);  //test OK
void ReadEE(void);   //?
void WriteEE(void);  //?

4. PICkit2 Firmware (Reserve the last 32 bytes block for signature 0x5555@0x7FFE

5. Download the firmware to PIC18F2550, OK.







No comments:

Post a Comment