News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Option to generate full hex file?

Started by trastikata, Jun 19, 2021, 05:26 PM

Previous topic - Next topic

trastikata

Hello,

I looked but couldn't find any information if Positron can generate complete hex files with all memory addresses similar to the ones exported by MPLAB IPE instead of the shorten files like currently created by Positron. 

To illustrate the question I've attached two files, the code is identical, but MPLABIPE.txt is the complete memory version of POSITRON.txt

Thank you



TimB


Not going to be able to answer your full question.

As long as I have been working with hex files from a Pic perspective as in the Bootloader. I never expect the file to be anything other than 16byte blocks with random addresses (in order though). Not consecutive blocks.

So sorry it not an answer but if your working on a bootloader then the pic can handle it with no issues.

trastikata

Quote from: TimB on Jun 19, 2021, 05:39 PMSo sorry it not an answer but if your working on a bootloader then the pic can handle it with no issues.

Well it makes handling the erasing and writing from my customized bootloader software easier, otherwise I have to write routines for calculating the block sizes etc. 

I asked if this option existed so I can skip the MPLAB IPE step, but it's not a big deal, two more mouse clicks - I only open the file with MPLAB IPE and then save it back as full hex.

top204

#3
It is the assembler program that creates the HEX file, not the compiler itself.

The HEX file you showed is a bloated HEX file with all the parts of flash memory not actually used, still filled with data. This is not the way a HEX file should operate. The first values on the left of the line contain the address of the data, so a HEX file parser should read the first part of each HEX file line, find its address.

A programmer or bootloader always sends the address first, then the block of data to write to the device, sometimes with the amount of data it is going to send, and sometimes a fixed amount depending on the device's fladh memory block write size, so the address is a way to shorten the time it takes to write to a device because it does not have to write pieces of memory that have not been used.

This has been standard proctice since HEX files were first created.

trastikata

Quote from: top204 on Jun 19, 2021, 07:09 PMThis has been standard proctice since HEX files were first created.

Thank you for the answer Les, In my case I have calibration information stored within the flash memory (no EEPROM) with the Org directive at the upper blocks in different addresses, the hex file is organized as 16 byte but the write block size is 64 bytes - all this complicates file reading and addressing the 64 byte boundaries. It is much simpler writing the entire memory and not calculating block boundaries. Anyway I simplified it with MPLAB IPE.

I was wondering what is the reason for MPLAB IPE to save files as full hex files? If you import a file and then export it, the file is saved as full memory image and not the short one.

TimB

#5
In case it helps here is a bootloader written for some one.

I hope I removed all the the id


       
                                                                           
;============================================ Compiler related defines ====================================================
                                 
    Device = 18F47J53                                                   ' NB PIC is 3V3
   
    Config_Start
    WDTEN = On                                                          ' Watchdog timer Enabled
    PLLDIV = 2                                                          ' Divide by 2 (8 MHz oscillator input) for 4MHz to PLL
    CFGPLLEN = On                                                       ' PLL Enable Configuration Bit (not on 18F46J50)
    STVREN = On                                                         ' Stack Overflow/Underflow Disabled
    XINST = OFF                                                         ' Extended Instruction Set Disabled
    CPUDIV = OSC1                                                       ' No divide CPU System Clock Divider - Divide by 1 for 48MHz   
    Cp0 = OFF                                                           ' Code Protection Off
    OSC = INTOSCPLL                                                     ' Internal Oscillator PLL (through software)                                                     
    CLKOEC = OFF                                                        ' Clock output disabled on RA6 pin
    FCMEN = OFF                                                         ' Fail-Safe Clock Monitor Disabled
    IESO = OFF                                                          ' Internal/External Oscillator Switch Over Disabled
    WDTPS = 16384                                                       ' Watchdog Postscaler set to 1:16384
    DSWDTOSC = INTOSCREF                                                ' DSWDT uses INTRC
    RTCOSC = T1OSCREF                                                   ' RTCC uses T1OSC/T1CK1
    DSBOREN = OFF                                                       ' Deep Sleep Brown-out Disabled
    DSWDTEN = OFF                                                       ' Deep Sleep Watchdog Timer Disabled
    DSWDTPS = 2048                                                      ' 1:2,048 (2.1 seconds)
    IOL1WAY = OFF                                                       ' The IOLOCK bit (PPSCON<0>) can be set and cleared as needed
    ADCSEL = BIT10                                                      ' ADC 10 Bit Selected
    MSSP7B_EN = MSK7                                                    ' 7 Bit address masking mode
    WPFP = PAGE_3                                                       ' Write Protect Program Flash Page 3
    WPCFG = OFF                                                         ' Configuration Words page not erase/write-protected
    WPDIS = OFF                                                         ' WPFP<6:0>/WPEND region ignored
    WPEND = PAGE_0                                                      ' Page 0 through WPFP<6:0> erase/write protected
    Config_End
             
    Declare Xtal = 48                                                   ' Clock = 48MHz (8MHz Int. Osc., PLL= /2, MCU Clock Division = /1)
    Declare Optimiser_Level = 3                                         ' Normally 3
    Declare Watchdog = On
    Declare Warnings = On
    Declare Reminders = On
    Declare Create_Coff = Off
    Declare Bootloader = Off
    Declare Dead_Code_Remove = On                                       ' Squeeze the code further
    Declare Stack_Size = 4
                                         
'   Define interrupt related registers
    Symbol RBIF = INTCON.0                                              ' RB Port Interrupt Flag
    Symbol INT0IF = INTCON.1                                            ' INT0 External Interrupt Flag
    Symbol TMR0IF = INTCON.2                                            ' TMR0 Overflow Interrupt Flag
    Symbol RBIE = INTCON.3                                              ' RB Port Change Interrupt Enable
    Symbol INT0IE = INTCON.4                                            ' INT0 External Interrupt Enable
    Symbol TMR0IE = INTCON.5                                            ' TMR0 Overflow Interrupt Enable
    Symbol TMR0IP = INTCON2.2                                           ' TMR0 Interrupt priority flag   
    Symbol PEIE = INTCON.6                                              ' Peripheral Interrupt Enable
    Symbol GIEL = INTCON.6                                              ' Peripheral Interrupt Enable
    Symbol GIE = INTCON.7                                               ' Global Interrupt Enable
    Symbol GIEH = INTCON.7                                              ' Global Interrupt Enable
    Symbol IPEN = RCON.7                                                ' Priority interrupt register
   
'   Define the flash memory register bits
    Symbol RD = EECON1.0                                                ' Read Control
    Symbol WR = EECON1.1                                                ' Write Control
    Symbol WREN = EECON1.2                                              ' EEPROM Write/Enable
    Symbol WRERR = EECON1.3                                             ' EEPROM Error Flag
    Symbol FREE = EECON1.4                                              ' FLASH Row Erase Enable bit
    Symbol CFGS = EECON1.6                                              ' FLASH Program/Data EEPROM or Configuration Select bit
    Symbol EEPGD = EECON1.7                                             ' FLASH Program or Data EEPROM Memory Select bit

' Port A - Set up PORT A for analogue input Relay and Circuit current sensing, GSM Heartbeat I/P and Reset O/P     
    TRISA = %01111111                                                   ' Configure as Bits 0-6 as analogue inputs, Bit 7 as O/P
    ADCON0 = %00011101                                                  ' Internal Vref, ports set for analogue AN0-7, ADON=1
    ANCON0 = %00000000                                                  ' AN0-7 Set as analogue inputs
    ANCON1 = %10011111                                                  ' Band Gap Generator On and AN8-12 disabled
    Declare Adin_Res 10                                                 ' 10-bit result required
    Declare Adin_Tad 32_FOSC                                            ' FOSC/32 oscillator chosen
    Declare Adin_Stime 50                                               ' Allow 50us sample time
       
'   Setup PORT B for I2C, Carrier Detect, Push Button and heater (PWM)
    TRISB = %10110111                   ' Set Bits 0-2 & 4,5, 7 as I/P, Bits 2 & 6 = O/P, 6 = PGC, 7 = PGD
    Symbol CD = PORTB.0                 ' VHF Receiver Carrier Detect
    Symbol CD_On = 0                    ' States for VHF Module Carrier Detect (Active Low)
    Symbol CD_Off = 1
    Symbol Push_Button = PORTB.1        ' VHF CD simulator Push Button
    Symbol Bootloader_Button = PORTB.1  ' Bootloader Push Button
    Symbol Pressed = 0
    Symbol Open = 1
    Symbol BMS_IP = PORTB.2             ' BMS Input (also on Pin 6 of J3-1)
    Symbol BMS3 = PORTB.3               ' BMS3 O/P relay
    Symbol SCL = PORTB.4                ' I2C Serial Clock
    Symbol SDA = PORTB.5                ' I2C Serial Data
    Symbol Heartbeat = PORTB.6          ' Heartbeat output
    Symbol PGC = PORTB.6
    Symbol PGD = PORTB.7         

'   Setup I2C - This software puts MSSP in Master I2C mode
    Declare Slow_Bus On
    Declare Hbus_Bitrate 100                                            ' No need for speed
    Symbol WCOL = SSP1CON1.7                                            ' Write Collision Detect bit - must be cleared in software
    Symbol SSPOV = SSP1CON1.6                                           ' Receive Overflow Indicator bit - must be cleared in software
    Symbol SSPEN = SSP1CON1.5                                           ' SSPEN: Master Synchronous Serial Port Enable bit
    Symbol ACKEN = SSP1CON2.4                                           ' Acknowledge Sequence Enable bit
    Symbol RCEN = SSP1CON2.3                                            ' Receive Enable bit (Master Receive mode only)
    Symbol PEN = SSP1CON2.2                                             ' Stop Condition Enable bit
    Symbol RSEN = SSP1CON2.1                                            ' Repeated Start Condition Enable bit
    Symbol SEN = SSP1CON1.0                                             ' Start Condition Enable bit
    Symbol RW = SSP1STAT.2                                              ' Read/Write Information bit
    Symbol SMP = SSP1STAT.7                                             ' Slew rate control bit
   
'   Setup PORT C for VHF Module I/O, serial 1 I/O - RS232 and USB
    TRISC = %10111110                                                   ' Set bits 0 & 6 as O/P rest as I/P
    Symbol VHF_PS = PORTC.0                                             ' VHF Power Select Output
    Symbol VHF_On = 0                                                   ' States for VHF Module PS line (Active Low)
    Symbol VHF_Off = 1
    Symbol VHF_OC1 = PORTC.1                                            ' VHF 'Open Collector' 1 input
    Symbol VHF_OC2 = PORTC.2                                            ' VHF 'Open Collector' 2 input
    Symbol USB_D_Minus = PORTC.4                                        ' USB D-
    Symbol USB_D_Plus = PORTC.5                                         ' USB D+   
    Symbol RS232TX1 = PORTC.6                                           ' RS232 1 Tx
    Symbol RS232RX1 = PORTC.7                                           ' RS232 1 Rx
    Symbol RC1IE = PIE1.5                                               ' Serial 1 Interrupt Enable
    Symbol RC1IF = PIR1.5                                               ' Serial 1 Interrupt Flag
    Symbol RC1IP = IPR1.5                                               ' Receive 1 Interrupt High Priority   

'   Setup for Serial Port 1 (GSM) at compile time this version
    Declare Hserial_TXSTA %00100000                                     ' Async, Tr1 enabled, 8 bit, low speed
'    Declare Hserial_TXSTA %00100100                                     ' Async, Tr1 enabled, 8 bit, high speed
    Declare Hserial_RCSTA %10010000                                     ' Serial port enabled, 8 bit, Rx1 enabled
    Declare Hserial_Baud 9600                                           ' If not set, default baud rate is 2400
    Declare Hserial_Clear On                                            ' Force ignore of I/P overflow - or Off
    Symbol OERR = RCSTA1.1                                              ' Over-run error flag bit
    Symbol CREN = RCSTA1.4                                              ' Continuous Run Enable (anables input and clears OERR)
                                       

    Declare Hserial2_TXSTA %00100000                                    ' Async, Tr2 enabled, 8 bit, low speed
'    Declare Hserial2_TXSTA %00100100                                    ' Async, Tr2 enabled, 8 bit, high speed
    Declare Hserial2_RCSTA %10010000                                    ' Serial port enabled, 8 bit, Rx2 enabled
    Declare Hserial2_Baud 9600                                          ' If not set, default baud rate is 2400
    Declare Hserial2_Clear On                                           ' Force ignore of I/P overflow - or Off
    Symbol OERR2 = RCSTA2.1                                             ' Over-run error flag bit
    Symbol CREN2 = RCSTA2.4                                             ' Continuous Run Enable (anables input and clears OERR)         
   
'   Setup PORT D - Relay & Heater Drivers, Meteo RS232 and BMS 1&2 O/Ps
    TRISD = %01100000                                                   ' Set bit 0, 3-5 & 7 as O/P, Bits 1-2 & 6 as IP
   
    Symbol xxxxx = PORTD.3                                             
    Symbol RS232TX2 = PORTD.4                                           ' RS232 2 TX
    Symbol RS232RX2 = PORTD.5                                           ' RS232 2 RX
    Symbol BMS_1 = PORTD.6                                              ' BMS1 O/P relay
    Symbol BMS_2 = PORTD.7                                              ' BMS2 O/P relay
    Symbol RC2IE = PIE3.5                                               ' Serial 2 Interrupt Enable
    Symbol RC2IF = PIR3.5                                               ' Serial 2 Interrupt Flag
    Symbol RC2IP = IPR3.5                                               ' Receive 2 Interrupt High Priority
                   
'   Setup PORT E - Relay 3 current, PSU Voltage and Temperature measurement
    TRISE = %00111111                                                   ' Set bits 0-6 as I/P, disable pull-ups on port E
       
;=== interrupt based defines ===============================

    On_Interrupt     GoTo USER_HIGH_INTERRUPT_VECTOR                    ; RE-MAP INT VECTORS
    On_Low_Interrupt GoTo USER_LOW_INTERRUPT_VECTOR                     ; RE-MAP INT VECTORS
   
;===============================================================

    Dim FSR_0 As FSR0L.Word
    Dim FSR_1 As FSR1L.Word
    Dim FSR_2 As FSR2L.Word
   
    ' General Variables
   
    Dim Index1 As Byte
    Dim Index2 As Byte
    Dim PromAddress As Dword
    Dim MemoryPointer As Dword
    Dim NextPromBlock As Dword
    Dim LastPromBlock As Dword
    Dim ArrayIndex As Dword
    Dim PromMemoryPointer As Dword
    Dim PWriteIndex As Word
    Dim TempB1 As Byte   
    Dim FirmwareAddress As Dword
    Dim BlockNeedsWritting As Bit
    Dim BootloaderVersion As Word

    Clear

; Main Pic related defines
   
    Symbol MainCodeStart            = $1000                             ; Main code start address / Keep on a 64 byte boundry 
    Symbol EndOfCodeSpace           = $F800                            ; End of program code space (This version over-writes CData tables) ## Temporary End ##
'    Symbol EndOfCodeSpace           = $1F800                            ; End of program code space (This version over-writes CData tables)
    Symbol FlashEraseSeg            = 1024                              ; The size of memory bank erased in one go
    Symbol FlashWriteBlock          = 64                                ; The memory size Flash write needs to do in one block
    Symbol USBDataBlock             = 16                                ; The number of bytes sent in a block

'--------------------------------------------------------------------------   

    Symbol LCD_Write = 0x40                                             ' I2C address for eAGLe LCD & Keypad Interface
    Symbol CR = 13                                                      ' Carriage Return       (CTRL-M)
   
'--------------------------------------------------------------------------
    Include "HID_Descriptor.inc"                                    ' Load the USB routines and descriptor into the program
'--------------------------------------------------------------------------
       
;***************************************************************************
;   Command List
;   Below is the list of commands available and info on them
;
    Symbol ReturnFirmWareVerNo      = $01                               ; Return the firmware number
    ; Bytes expected 1 (command)   
    ; returns 2 bytes Low byte first  x.y Were the lower byte is y
       
    Symbol ReturnBootloaderVerNo    = $02                               ; Return the firmware number
    ; Bytes expected 1 (command)   
    ; returns 2 bytes Low byte first  x.y Were the lower byte is y

    Symbol WriteFlash               = $20                               ; Write Y bytes from Prom at X,X,X address Note next packet via USB has the data
    ; Bytes expected 5 (command) + bytes to write + 3 address bytes   
    ; Returns $55 via USB when done
   
    Symbol RunMainCode              = $21                               ; Run the main code above the bootloader
       
    Symbol FinishWrite              = $22                               ; Finish the write
    ; Bytes expected 1 (command)
    ; Returns $55 via USB then and writes to eeprom to finish the write sequence
   
    Symbol EraseProgram             = $23                               ; Erase memory
    ; Bytes expected 1 (command)
    ; Returns $55 via USB when done

    Dim FirmWareVerAlias As Word At TXReport#0               
    Dim USBCommandIn As Byte At RXReport#0
    Dim OffsetReadAlias As Byte At RXReport#1
    Dim StartAddressAlias As Word At RXReport#1 
    Dim ByteCountAlias As Byte At RXReport#5
    Dim DataStartAlias As Byte At RXReport#6   
    Dim TXReportReport1 As Word At TXReport#2             
    Dim TempMemoryArray[FlashWriteBlock] As Byte
   
    GoTo ProtonCodeStart

;===============================================================

; Pseudo Commands
   
' ************************************************************
' * program starts here...                                   *
' ************************************************************

ProtonCodeStart:
; Here we set up the pic as required and decide if were running USB Download mode or main code

    OSCTUNE.6 = 1                                                       ' Enable PLL (Only needed for 18F46J50)
    EECON1.2 = 1                                                        ' Allow write cycles to Flash Program Memory
    EECON2 = 0x55                                                       ' 18F47J53 requires mapping of PWM O/P to port pin
    EECON2 = 0xAA                                                       ' Must be first action
    Clear PPSCON.0                                                      ' Unlock Mapping control register
    RPOR20 = 14                                                         ' Map CCP1/P1A (PWM chan. A) to RP20 (RD3) (V1.1-3 RP6 (RB3))
    RPOR21 = 5                                                          ' Map TX2/CK2 to RP21 - Added mapping of Tx2/Rx2 for Hardware V1.2
    RPINR16 = 22                                                        ' Map RP22 to RX2/CK2
    EECON2 = 0x55                                                       ' Write register
    EECON2 = 0xAA
    Set PPSCON.0                                                        ' Re-lock Mapping control register
           
    DelayMS 10                                                          ; A delay for all to settle
   
'' ************************************************************
''  Check if we are in Bootload mode - checks button and flag
'' 
'' ************************************************************           
   
Check_Bootloader:
    If Bootloader_Button = Pressed Then GoTo Start_Bootloader           ' If bootloader button pressed on start-up, run bootloader
    Nop
    @ GoTo MainCodeStart

Start_Bootloader:
    BootloaderVersion = CRead BootVersionNo 
    DelayMS 250


    GoTo USBMode
                                                                        ; Jump to USB mode
' ************************************************************
' * receive data from the USB bus                            *
' ************************************************************
DoUSBIn:
    While 1 = 1                                                         ' Loop until we have data
        mUSBService()
        If HID_DataAvailable() = True Then
            HID_ReadReport()                         
            Return
        EndIf
        Clrwdt
    Wend
   
' ************************************************************
' * transmit data                                            *
' ************************************************************
DoUSBOut: 

    HID_WriteReport()                                         
    Return
   
' ************************************************************
'  Write the Data From the usbbuffer into flash ram
'  $20, address 4 bytes, payload 
' ************************************************************     
WriteFlashData:

    PromAddress = StartAddressAlias
    Index2 = ByteCountAlias - 1       

    If PromAddress < MainCodeStart Then                                 ; If the address were being requested to write to is not in the correct place then we just return                                                                                                                                       
        GoSub USBOK_Responce                                            ; NOTE you can add more checks here to prevent areas being over written
        Return
    EndIf
   
    GoSub WriteToProm                                                   ; Write that into the memory block and into Prom
   
    GoSub USBOK_Responce                                                ; Send the good news
   
    Return
   
; end of WriteFlashData sub
   
;==============================================================

' ************************************************************
'  Write over that Memory block the required data
'  Then write that to Prom
' ************************************************************
WriteToProm:     

    MemoryPointer = PromAddress                                         ; Make a note of the address of where we want to save the data as indicated in the hex file
    ArrayIndex = MemoryPointer & $3F                                    ; Mask and shift this number to give us an Array index     

    If MemoryPointer >= NextPromBlock Then                              ; Check we have not moved into the next Block if so then ......
        GoSub WriteArrayToMemory                                        ; Write the Memory block to SFlash
        Clear TempMemoryArray                                           ; And clear the Array
        NextPromBlock = MemoryPointer & $1FFC0                           ; Work out the address for the next Prom Block so we can perform the same test in future
        NextPromBlock = NextPromBlock + FlashWriteBlock
        LastPromBlock = MemoryPointer & $1FFC0                           ; We need to have this in case we start writting in the middle of a block and not the start
    EndIf

; Now copy the data from the USB report into our working array

WriteToPromEntry2:

    FSR_2 = VarPtr DataStartAlias                                       ; point to the incoming data
   
    Index1 = 0                                                          ; Loop through the x (16) bytes from the USB report into the array
    Repeat
        TempB1 = POSTINC2
        TempMemoryArray[ArrayIndex] = TempB1
        Inc Index1
        Inc ArrayIndex   
    Until Index1 >= USBDataBlock                                        ; keep writting until the packet of data sent is saved to our array
    BlockNeedsWritting = True
    Return

' ************************************************************
'  Routine to write the block to memory

' ************************************************************       
WriteArrayToMemory:

;The following Code writes a 64? Byte block from our working Array to Prom

    If BlockNeedsWritting = False Then                                  ; Prevents blocks being written on start up
        Return
    EndIf

    PromMemoryPointer = LastPromBlock                                   ; Since we got called when we moved on from a previous block we need to save the previous block

    PWriteIndex = 0
    Repeat
        CWrite PromMemoryPointer, [TempMemoryArray[PWriteIndex]]        ' Write the data to memory
        Inc PromMemoryPointer
        Inc PWriteIndex
    Until PWriteIndex >= FlashWriteBlock                                ' Loop through the block
    BlockNeedsWritting = False   
Return
   
' ************************************************************
'  Erase all of program memory above the boot loader line to the user storage area whcih will be dealt with later

' ************************************************************   
EraseProgramData:
   
    ; Clear all of Flash above the bootloader to the end of Prom set by EndOfCodeSpace
   
    PromAddress = MainCodeStart
   
    Repeat
        CErase PromAddress
        PromAddress = PromAddress + FlashEraseSeg
        mUSBService()                                                   ; It can be a lengthy process so service the USB as we go
    Until PromAddress >= EndOfCodeSpace

    Return
                       
;==============================================================

' ************************************************************
'  Routine to mark the bootload finished and finalaise any writes

' ************************************************************
WriteBootFinished:
   
    If BlockNeedsWritting = True Then                                   ' If we are half way through a block and not saved it yet
        GoSub WriteArrayToMemory                                        ' Do so
    EndIf   
    Return

' ************************************************************
'  Read the firmware version from rom and send out via USB

' ************************************************************
ReadFirmWareNo:
    FirmWareVerAlias = CRead FirmwareAddress 
    GoSub DoUSBOut
    Return
   
; Send OK back on USB
USBOK_Responce:
    TXReport#0 = $55
    GoSub DoUSBOut
    Return
       
; Send back Not ok responce
USBNotOK_Responce:
    TXReport#0 = $AA
    GoSub DoUSBOut
    Return
   
;=== This is the main USB mode loop =========================
USBMode:
   
    LastPromBlock =  MainCodeStart
    BlockNeedsWritting = False
       
    While 1 = 1                                                         ; Main Loop Runs here
                       
        GoSub DoUSBIn                                                   ; Get the next command
               
        Clear TXReport                                                  ; Clear the outgoing report of previous data
       
        Select USBCommandIn

            Case ReturnFirmWareVerNo                                    ; Return the main code Version Number
                FirmwareAddress = CodeVerNo                             ; (EndOfCodeSpace - 10)         
                GoSub ReadFirmWareNo 
           
            Case ReturnBootloaderVerNo
                FirmwareAddress = BootVersionNo                         ; Return the Bootloader version Number
                GoSub ReadFirmWareNo
               
            Case EraseProgram                                           ; Erase Program memory
                GoSub EraseProgramData                                             
                GoSub USBOK_Responce
               
            Case WriteFlash                                             ;  Write Y bytes from Prom at X,X,                       
                GoSub WriteFlashData
                             
            Case FinishWrite                                            ; Set the appropriate flags to say it was a successful firmware update           
                GoSub WriteBootFinished     
                GoSub USBOK_Responce

                HBusOut LCD_Write, [CR, "S/W Updated OK", CR, "Restart Controller"]
                               
            Case RunMainCode               
                GoSub USBOK_Responce
                @ GoTo MainCodeStart                                    ; Run the main code above the Bootloader
               
        EndSelect
           
    Wend


Org  MainCodeStart - 10

BootVersionNo:
    CData As Word $010A                                                 ; Bootloader Code version XXYY  XX = major YY = Minor
   
Org  MainCodeStart                                                      ; Where the main code will sit
   
Org  MainCodeStart + $8                                                 ; Interrupt redirection vector points
USER_HIGH_INTERRUPT_VECTOR:
Org MainCodeStart + $18
USER_LOW_INTERRUPT_VECTOR:


Org EndOfCodeSpace - 10                                                        ;(EndOfCodeSpace - 10)
CodeVerNo:
    CData As Word $0001                                                 ; Code version XXYY  XX = major YY = Minor

top204

#6
Whenever a programmer executable saves a HEX file from a device that has been read, it has to fill all the device's addresses because it does not know what is used and what is not used, unlike the assembler program itself.