This is where I am so far. I am sure there are some errors, but what are friends for?
Code:' ***************************************************************************** ' Software License Agreement ' ' The software supplied herewith by PBP forum members ' (the “Company”) for Microchip's PICmicro® Microcontroller's is ' intended and supplied to you, the Company’s customer, for use ' solely and exclusively on Microchip PICmicro Microcontroller ' products. The software is owned by the Company and/or its ' supplier, and is protected under applicable copyright laws. All ' rights are reserved. Any use in violation of the foregoing ' restrictions may subject the user to criminal sanctions under ' applicable laws, as well as to civil liability for the breach of ' the terms and conditions of this license. ' ' THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, ' WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED ' TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A ' PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, ' IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR ' CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. ' ' ' This software has been ported from Microchip's AN851 bootloader ' Changes have been made and will be made as the company sees fit. ' This version is for 16F's, there is another version for 18F's ' ' ' Memory Map ' ----------------- ' | 0x0000 | Reset vector ' | | ' | 0x0004 | Interrupt vector ' | | ' | | ' |Boot Block | (this program) ' | | ' | 0x0200 | Re-mapped Reset Vector ' | 0x0204 | Re-mapped High Priority Interrupt Vector ' | | ' | | ' | | ' |Code Space | User program space ' | | ' | | ' | | ' | 0x3FFF | ' ----------------- ' ' Incomming data format: ' ' <STX><STX><DATA><CHKSUM><ETX> ' / \ ' ________/ \____________________________ ' / \ ' <COMMAND><DLEN><ADDRL><ADDRH><ADDRU><DATA>... ' ' Definitions: ' ' STX - Start of packet indicator ' ETX - End of packet indicator ' LEN - Length of incomming packet ' DATA - General data up to 255 bytes ' CHKSUM - The 8-bit two's compliment sum of LEN & DATA ' COMMAND - Base command ' DLEN - Length of data associated to the command ' ADDR - Address up to 24 bits ' DATA - Data (if any) ' ' ' Commands: ' ' RD_VER 0x00 Read Version Information ' RD_MEM 0x01 Read Program Memory ' WR_MEM 0x02 Write Program Memory ' ER_MEM 0x03 Erase Program Memory (NOT supported by PIC16) ' RD_EE 0x04 Read EEDATA Memory ' WR_EE 0x05 Write EEDATA Memory ' RD_CONFIG 0x06 Read Config Memory (NOT supported by PIC16) ' WT_CONFIG 0x07 Write Config Memory (NOT supported by PIC16) ' ' **************************************************************************** ' ***************************************************************************** CHKSUM VAR BYTE ' Checksum accumulator COUNTER VAR BYTE ' General counter ABTIME VAR BYTE RXDATA VAR BYTE TXDATA VAR BYTE TEMP VAR BYTE PCLATH_TEMP VAR BYTE ' Interrupt context STATUS_TEMP VAR BYTE ' save/restore registers W_TEMP VAR BYTE ' Frame Format ' ' <STX><STX>[<COMMAND><DATALEN><ADDRL><ADDRH><ADDRU><...DATA...>]<CHKSUM><ETX> DATA_BUFF VAR BYTE ' Start of receive buffer SAME ADDRESS AS COMMAND COMMAND VAR BYTE ' Data mapped in receive buffer SAME ADDRESS AS DATA_BYTE DATA_COUNT VAR BYTE ADDRESS_L VAR BYTE ADDRESS_H VAR BYTE ADDRESS_U VAR BYTE PACKET_DATA VAR BYTE 'THIS SHOULD BE AN ARRAY I THINK************** ' ***************************************************************************** ' This is the remapping section, note the interrupt also saves context ' ***************************************************************************** @ ORG 0x0000 ' Re-map Reset vector **Not sure how to set the address to start at VReset: PCLATH = 0 goto Setup @ ORG 0x0004 'standard interrupt vector **again not sure of the PBP equal for ORG VInt: W_TEMP = W 'I am assuming this will be the "W" register STATUS_TEMP = STATUS 'We may have trouble here. ASM uses SWAP so as not to affect the status STATUS = 0 PCLATH_TEMP = PCLATH PCLATH = 0 goto RVInt ' Re-map Interrupt vector ; ***************************************************************************** ***************************************************************************** ; Setup the appropriate registers. Setup: clrwdt READ $ff,temp 'get the value of last EEPROM location IF temp = $ff then goto SRX 'BL startup goto RVReset ' If not 0xFF then normal reset SRX: RCSTA = b'10000000' ' Setup rx and tx, CREN disabled TRISC.6 = 0 ' Setup tx pin TXSTA = b'00100110' STATUS.IRP = 1 ; *****************************************************************************
Well it formats much better in notepad++. well I tried to attach the code, but had some issues there. but for now, the code is as I wrote it, just the comments are messed up.





Bookmarks