+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    230

    Default Tiny Bootloader and PIC18F27K40

    Hi all,

    I've been trying to get the tiny bootloader to work on the PIC18F27K40 and I am so close but hit a wall because I'm fumbling in the dark when it comes to assembly and the flash writing mechanism. I'm hoping someone can help me here.

    Stripped down version of the test program to flash an LED:
    Code:
      #CONFIG
        CONFIG FEXTOSC = HS	        ;HS (crystal oscillator) above 8 MHz; PFM set to high power
        CONFIG RSTOSC = EXTOSC	    ;EXTOSC operating per FEXTOSC bits (device manufacturing default)
        CONFIG CLKOUTEN = OFF	      ;CLKOUT function is disabled
        CONFIG CSWEN = ON	          ;Writing to NOSC and NDIV is allowed
        CONFIG FCMEN = OFF          ;Fail-Safe Clock Monitor disabled
        CONFIG MCLRE = INTMCLR	    ;If LVP = 0, MCLR pin function is port defined function; If LVP =1, RE3 pin fuction is MCLR 
        CONFIG PWRTE = ON	          ;Power up timer enabled
        CONFIG LPBOREN = ON 	      ;ULPBOR enabled
        CONFIG BOREN = SBORDIS	    ;Brown-out Reset enabled , SBOREN bit is ignored
        CONFIG BORV = VBOR_285	    ;Brown-out Reset Voltage (VBOR) set to 2.85V
        CONFIG ZCD = OFF	          ;ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
        CONFIG PPS1WAY = ON	        ;PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle
        CONFIG STVREN = ON	        ;Stack full/underflow will cause Reset
        CONFIG DEBUG = OFF	        ;Background debugger disabled
        CONFIG XINST = OFF	        ;Extended Instruction Set and Indexed Addressing Mode disabled
        CONFIG WDTCPS = WDTCPS_31	  ;Divider ratio 1:65536; software control of WDTPS
        CONFIG WDTE = OFF	          ;WDT Disabled
        CONFIG WDTCWS = WDTCWS_7	  ;window always open (100%); software control; keyed access not required
        CONFIG WDTCCS = LFINTOSC	  ;WDT reference clock is the 31.0 kHz LFINTOSC
        CONFIG WRT0 = OFF	    ;Block 0 (000800-003FFFh) not write-protected
        CONFIG WRT1 = OFF	    ;Block 1 (004000-007FFFh) not write-protected
        CONFIG WRT2 = OFF	    ;Block 2 (008000-00BFFFh) not write-protected
        CONFIG WRT3 = OFF	    ;Block 3 (00C000-00FFFFh) not write-protected
        CONFIG WRT4 = OFF	    ;Block 4 (010000-013FFFh) not write-protected
        CONFIG WRT5 = OFF	    ;Block 5 (014000-017FFFh) not write-protected
        CONFIG WRT6 = OFF	    ;Block 6 (018000-01BFFFh) not write-protected
        CONFIG WRT7 = OFF	    ;Block 7 (01C000-01FFFFh) not write-protected
        CONFIG WRTC = OFF	    ;Configuration registers (300000-30000Bh) not write-protected
        CONFIG WRTB = OFF	    ;Boot Block (000000-0007FFh) not write-protected
        CONFIG WRTD = OFF	    ;Data EEPROM not write-protected
        CONFIG SCANE = OFF	  ;Scanner module is NOT available for use, SCANMD bit is ignored
        CONFIG LVP = OFF	    ;HV on MCLR/VPP must be used for programming
        CONFIG CP = OFF	      ;UserNVM code protection disabled
        CONFIG CPD = OFF	    ;DataNVM code protection disabled
        CONFIG EBTR0 = OFF	  ;Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
        CONFIG EBTR1 = OFF	  ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
        CONFIG EBTR2 = OFF	  ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
        CONFIG EBTR3 = OFF	  ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
        CONFIG EBTR4 = OFF	  ;Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
        CONFIG EBTR5 = OFF	  ;Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
        CONFIG EBTR6 = OFF	  ;Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
        CONFIG EBTR7 = OFF	  ;Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
        CONFIG EBTRB = OFF	  ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
      #ENDCONFIG
    
    DEFINE OSC 16
    DEFINE NO_CLRWDT 1      ' Don't waste cycles clearing WDT
    @ ERRORLEVEL -306       ; turn off crossing page boundary message
    CLEAR                   ' Set all registers to 0
    
    PORTA = %00000000       ' Turn Off Port
    TRISA = %00000000       ' Set PortA I/Os
    WPUA = 0                ' PortA Weak Pull Ups disabled
    ODCONA = 0              ' PortA Open Drain control. 1= sink, 0= src & sink
    SLRCONA = 0             ' PortA Slew Rate control. 1= limited, 0= max rate
    INLVLA = 0              ' PortA Input Level control. 1= ST, 0= TTL for IOC
    
    PORTB = %00000000       ' Turn Off Port
    TRISB = %11000001       ' Set PortB I/Os
    WPUB = 0                ' PortB Weak Pull Ups disabled
    ODCONB = 0              ' PortB Open Drain control. 1= sink, 0= src & sink
    SLRCONB = 0             ' PortB Slew Rate control. 1= limited, 0= max rate
    INLVLB = 0              ' PortB Input Level control. 1= ST, 0= TTL for IOC
    
    PORTC = %00000000       ' Turn Off Port
    TRISC = %10101000       ' Set PortC I/Os
    WPUC = 0                ' PortC Weak Pull Ups disabled
    ODCONC = 0              ' PortC Open Drain control. 1= sink, 0= src & sink
    SLRCONC = 0             ' PortC Slew Rate control. 1= limited, 0= max rate
    INLVLC = 0              ' PortC Input Level control. 1= ST, 0= TTL for IOC
     
    ADCON0.0 = 0            ' ADC module turned Off
    ANSELA = 0              ' PORTA A/D module disabled
    ANSELB = 0              ' PORTB A/D module disabled
    ANSELC = 0              ' PORTC A/D module disabled
    CM1CON0.7 = 0		        ' Comparator #1 OFF
    CM2CON0.7 = 0		        ' Comparator #2 OFF
    CCP1CON.7 = 0           ' CCP1 module disabled
    CCP2CON.7 = 0           ' CCP2 module disabled
    CWG1CON0.7 = 0          ' CWG module disabled
    DAC1CON0.7 = 0          ' DAC is disabled
    FVRCON = 0              ' FVR and TIM modules disabled
    ZCDCON.7 = 0            ' ZCD module disabled
    PWM3CON.7 = 0           ' PWM3 is disabled
    PWM4CON.7 = 0           ' PWM4 is disabled
    SSP1CON1.5 = 0          ' MSSP module disabled
    PIE0.4 = 1              ' IOC enabled
    IOCEN.3 = 1             ' IOC on negative edge register enabled
    IOCEP.3 = 1             ' IOC on positive edge register enabled
    
    ' See DS section 7.4 for definitions, "0" enables peripheral
    PMD0 = %01111110        ' System Clock network and IOC module enabled
    PMD1 = %11111110        ' TMR0 enabled
    PMD2 = %11111111        '
    PMD3 = %11111111        '
    PMD4 = %00111111        ' Enable EUSART1 & 2. "0" enables peripheral
    PMD5 = %11111111        '
    
    ' See DS section 17 for PPS I/O.
    RX1PPS = $13            ' UART1 RX1 moved to RC3, DS 17.9.1
    RX2PPS = $15            ' UART2 RX2 moved to RC5
    RC2PPS = $09            ' RC2 selected for UART1 TX1, DS 17.2, $09 = EUSART1 (TX/CK)
    RC4PPS = $0B            ' RC4 selected for UART2 TX2, $0B = EUSART1 (TX/CK) 
    PPSLOCK.0 = 1           ' PPS settings locked, no changes allowed
    
    '========================================================================
    '                        Variable PORT Definitions      
    '========================================================================
    Ser_RX_LED    VAR LATA.0    ' Serial RX LED indicator
    Ser_TX_LED    VAR LATA.1    ' Serial TX LED indicator
    
    Pwr_Save      VAR PORTB.0   ' STN2120 Power Save output for wake up signal
    OBD_Sleep     VAR LATB.1    ' System Sleep control. 0= Sleep
    Reset         VAR LATB.2    ' OBD2 Reset input. 0= Reset
    Pwr_Dwn       VAR LATB.3    ' RS232 TX Power Down. 1= Enable
    Ser_RX_EN     VAR LATB.4    ' RS232 RX Input enable. 0= Enable
    
    RTS           VAR LATC.6    ' Serial RTS signal output
    CTS           VAR PORTC.7   ' Serial CTS signal input
    
    '========================================================================
    '                        Variable Definitions      
    '========================================================================
    VARs:
    
    Dummy       VAR BYTE        ' Used to clear RC2REG
    Dest_add    VAR BYTE        ' Destination address to modem
    Ser_RX1     VAR BYTE[15]    ' Serial RX1 data 15 bytes long 
    UART_RXa    VAR BYTE[44]    ' Serial RX2 data 1st set 44 bytes from STN2120
    UART_RXb    VAR BYTE[44]    ' Serial RX2 data 2nd set 44 bytes from STN2120
    UART_Val    VAR BYTE[8]     ' Converted ASCII to number value
    UART_bytes  VAR BYTE        ' Number of bytes received from STN2120
    Ser_TX1     VAR BYTE[14]    ' Serial TX data 14 bytes long
    UART_TX     VAR BYTE        ' UART TX data variable for STN2120
    Ser_Dat     VAR BYTE        ' Serial TX1 data variable for the SER1 TX routine
    RX1_CKSM    VAR BYTE        ' Serial RX1 data checksum calculated variable
    TX1_CKSM    VAR BYTE        ' Serial TX1 data checksum calculated variable
    VIN         VAR BYTE[17]    ' VIN array variable
    VIN_data    VAR BYTE[34]    ' VIN 2 byte ASCII value array holder
    byte_loc    VAR BYTE        ' VIN Lookup variable
    DataA       VAR BYTE        ' ASCII convert variable
    DataB       VAR BYTE        ' ASCII convert variable
    DataC       VAR BYTE        ' ASCII convert variable
    DataD       VAR BYTE        ' ASCII convert variable
    
    Thou        VAR WORD        ' ASCII convert variable
    Hund        VAR WORD        ' ASCII convert variable
    Tens        VAR BYTE        ' ASCII convert variable
    sum         VAR BYTE        ' Calculation variable
    a           VAR BYTE        ' RX1 interrupt loop counter
    b           VAR BYTE        ' RX2 interrupt loop counter
    c           VAR BYTE        ' UART_TX loop counter
    d           VAR BYTE        ' UART_RX loop counter
    e           VAR BYTE        ' Serial TX loop counter
    f           VAR BYTE        ' ASCII loop counter
    x           VAR BYTE        ' RX2 loop limit counter
    Mode        VAR BYTE        ' Mode value sent to MG90
    PID         VAR BYTE        ' PID value sent to MG90
    STN         VAR BYTE        ' Memory read variable
    Stat        VAR BYTE
    ' .0 = UART#1 RX started
    ' .1 = UART#1 RX completed
    ' .2 = UART#2 RX started
    ' .3 = UART#2 RX completed
    ' .4 = STN2120 routine selected
    ' .5 = TMR0 TOT
    ' .6 = Sleep mode (for current testing)
    
    Store_B     VAR BYTE        ' PORTB IOC snapshot
    Store_C     VAR BYTE        ' PORTC IOC snapshot
    
    '//////////////////// Alias timer variables //////////////////////////////
    TMR_0        VAR WORD        ' Timer0 preload variable
    
    '=========================================================================
    
    EUSARTs:
    '=========================================================================
    '                           EUSART #1 
    '=========================================================================
    
    RC1STA = $90       ' Enable serial port & continuous receive
    TX1STA = $20       ' Enable transmit, BRGH = 0
    SP1BRGL = 51       ' 19200 Baud @ 16MHz, 0.16%
    SP1BRGH = 0
    BAUD1CON.3 = 1     ' Enable 16 bit baudrate generator
    
    '=========================================================================
    '                           EUSART #2 
    '=========================================================================
    
    RC2STA = $90         ' Enable serial port & continuous receive
    TX2STA = $20         ' Enable transmit, BRGH = 0
    SP2BRGL = 51         ' 19200 Baud @ 16MHz, 0.16%
    SP2BRGH = 0
    BAUD2CON.3 = 1       ' Enable 16 bit baudrate generator
    
    '=========================================================================
    '                       Set values to variables       
    '=========================================================================
    Dest_add = $40    ' Default address but can be changed on the fly for testing
    Ser_TX_LED = 0    ' Turn Off Serial output RJ45 RED LED
    Ser_RX_LED = 0    ' Turn Off Serial output RJ45 GRN LED
    Ser_RX_EN = 0     ' Enable Serial RX
    Pwr_Dwn = 1       ' Enable Serial TX
    OBD_Sleep = 1     ' Sleep mode disabled, 0 = Sleep enable
    Reset = 1         ' OBD2 reset disabled, 0 = Reset enable
    Stat = 0          ' Clear all status flags
    CTS = 1           ' Set CTS signal OFF
    
    PAUSE 100
    
    Main:
    
      TOGGLE Ser_TX_LED
      PAUSE 100
      
    GOTO Main
    
    END
    Here's my modified TinyBootloader.asm that assigns UART #1 to RC2 and RC3:
    Code:
    	radix DEC
    	LIST   P=PIC18F27K40	; change also: Configure->Select Device from MPLAB
    xtal EQU 20000000		; you may want to change: _XT_OSC_1H  _HS_OSC_1H  _HSPLL_OSC_1H
    baud EQU 19200			; standard TinyBld baud rates: 115200 or 19200
    	; The above 3 lines can be changed and built a bootloader for the desired frequency (and PIC type)
    	
    	;********************************************************************
    	;	Tiny Bootloader		18F series		Size=222words as of 9/2/2019
    	;	claudiu.chiculita@ugal.ro
    	;	http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm
    	;	
    	;   Modified by LinkMTech to work with the PIC18F27K40 PPS directives
    	;   and EEPROM name changes.
    	;   icdpictypes.inc was also modified to include the PIC18F27K40
    	;********************************************************************
    
    ;	This source file is for PIC18F27K40
    
    	#include "icdpictypes.inc"	; Takes care of: #include "p18fxxx.inc",  max_flash, IdTypePIC
    ;	#include "bankswitch.inc"   ; Purpose? Half loads program with or without
    
    		#define first_address max_flash-256		;adjust to Bootloader size
    
            CONFIG FEXTOSC = HS	        ;HS (crystal oscillator) above 8 MHz; PFM set to high power
            CONFIG RSTOSC = EXTOSC	    ;EXTOSC operating per FEXTOSC bits (device manufacturing default)
            CONFIG CLKOUTEN = OFF	      ;CLKOUT function is disabled
            CONFIG CSWEN = ON	          ;Writing to NOSC and NDIV is allowed
            CONFIG FCMEN = OFF          ;Fail-Safe Clock Monitor disabled
            CONFIG MCLRE = INTMCLR	    ;If LVP = 0, MCLR pin function is port defined function; If LVP =1, RE3 pin fuction is MCLR 
            CONFIG PWRTE = ON	          ;Power up timer enabled
            CONFIG LPBOREN = ON 	      ;ULPBOR enabled
            CONFIG BOREN = SBORDIS	    ;Brown-out Reset enabled, SBOREN bit is ignored
            CONFIG BORV = VBOR_285	    ;Brown-out Reset Voltage (VBOR) set to 2.85V
            CONFIG ZCD = OFF	          ;ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
            CONFIG PPS1WAY = ON	        ;PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle
            CONFIG STVREN = ON	        ;Stack full/underflow will cause Reset
            CONFIG DEBUG = OFF	        ;Background debugger disabled
            CONFIG XINST = OFF	        ;Extended Instruction Set and Indexed Addressing Mode disabled
            CONFIG WDTCPS = WDTCPS_31	  ;Divider ratio 1:65536; software control of WDTPS
            CONFIG WDTE = OFF	          ;WDT Disabled
            CONFIG WDTCWS = WDTCWS_7	  ;window always open (100); software control; keyed access not required
            CONFIG WDTCCS = LFINTOSC	  ;WDT reference clock is the 31.0 kHz LFINTOSC
            CONFIG WRT0 = OFF	    ;Block 0 (000800-003FFFh) not write-protected
            CONFIG WRT1 = OFF	    ;Block 1 (004000-007FFFh) not write-protected
            CONFIG WRT2 = OFF	    ;Block 2 (008000-00BFFFh) not write-protected
            CONFIG WRT3 = OFF	    ;Block 3 (00C000-00FFFFh) not write-protected
            CONFIG WRT4 = OFF	    ;Block 4 (010000-013FFFh) not write-protected
            CONFIG WRT5 = OFF	    ;Block 5 (014000-017FFFh) not write-protected
            CONFIG WRT6 = OFF	    ;Block 6 (018000-01BFFFh) not write-protected
            CONFIG WRT7 = OFF	    ;Block 7 (01C000-01FFFFh) not write-protected
            CONFIG WRTC = OFF	    ;Configuration registers (300000-30000Bh) not write-protected
            CONFIG WRTB = OFF	    ;Boot Block (000000-0007FFh) not write-protected
            CONFIG WRTD = OFF	    ;Data EEPROM not write-protected
            CONFIG SCANE = OFF	  ;Scanner module is NOT available for use, SCANMD bit is ignored
            CONFIG LVP = OFF	    ;HV on MCLR/VPP must be used for programming
            CONFIG CP = OFF	      ;UserNVM code protection disabled
            CONFIG CPD = OFF	    ;DataNVM code protection disabled    
            CONFIG EBTR0 = OFF	  ;Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
            CONFIG EBTR1 = OFF	  ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
            CONFIG EBTR2 = OFF	  ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
            CONFIG EBTR3 = OFF	  ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
            CONFIG EBTR4 = OFF	  ;Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
            CONFIG EBTR5 = OFF	  ;Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
            CONFIG EBTR6 = OFF	  ;Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
            CONFIG EBTR7 = OFF	  ;Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
            CONFIG EBTRB = OFF	  ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
    
    
    ;----------------------------- PROGRAM ---------------------------------
    	cblock 0
    	crc
    	i
    	cnt1
    	cnt2
    	cnt3	
    	counter_hi
    	counter_lo
    	flag
    	endc
    	cblock 10
    	buffer:64
    	dummy4crc
    	endc
    	
    SendL macro car
    	movlw car
    	movwf TX1REG   ; was TXREG
    	endm
    	
    ;0000000000000000000000000 RESET 00000000000000000000000000
    
    		ORG     0x0000            ; was 0x0000. moved to Bank 1
    		GOTO    IntrareBootloader
    
    ;view with TabSize=4
    ;&&&&&&&&&&&&&&&&&&&&&&&   START     &&&&&&&&&&&&&&&&&&&&&&
    ;----------------------  Bootloader  ----------------------
    ;PC_flash:		C1h				U		H		L		x  ...  <64 bytes>   ...  crc	
    ;PC_eeprom:		C1h			   	40h   EEADR   EEDATA	0		crc					
    ;PC_cfg			  C1h			U OR 80h	H		L		1		byte	crc
    ;PIC_response:	   type `K`
    	
    	ORG first_address		;space to deposit first 4 instr. of user prog.
    	nop
    	nop
    	nop
    	nop
    	org first_address+8
    	
    IntrareBootloader
     
    ; Required to operate
    	Banksel ANSELC
      movlw b'00000000'		
    	movwf ANSELC			;Disable analog on Tx/Rx pins     
      
    ; UART1 RX1 moved to RC3
      Banksel RX1PPS    ; go to bank with RX1PPS registers
      movlw 0x13        ; load value of RC3
      movwf RX1PPS      ; to RX1PPS register
      
    ; RC2 selected for UART1 TX1  
      Banksel RC2PPS    ; go to bank with RC2PPS registers
      movlw 0x09        ; load value for TX1
      movwf RC2PPS      ; to RC2PPS register
    
    							;Manually init serial port #1. Verified 19.23kb							
    ; Modified UART1 values and names. Verified TX speed @ 19.2kb						
    	movlw b'10010000'     ; Enable serial port & continuous receive = $90
    	movwf RC1STA          ; Changed from RXSTA
    
    	movlw b'00100000'     ; 5: Enable transmit, :2 BRGH = 0
    	movwf TX1STA          ; Changed from TXSTA
    
    	movlw b'00110011'      ;spbrgl_value = 51  
    	movwf SP1BRGL          ; Changed from SPBRG
    	movlw b'00000000'      ;spbrgh_value = 0
    	movwf SP1BRGH          ; Changed from SPBRG	
    
    	movlw b'00001000'      ;spbrg_value, 16-bit Baud rate generator used
    	movwf BAUD1CON         ; Added BAUD1CON	
    
    							;wait for computer
      rcall Receive  			
    	sublw 0xC1				     ;Expect C1h
    	bnz way_to_exit
    	SendL IdTypePIC			   ;send PIC type from "icdpictypes.inc", $C6
    	
    MainLoop
    	SendL 'K'				      ; "-Everything OK, ready and waiting."
    mainl
    	clrf crc
    	rcall Receive			    ;Upper
    	movwf TBLPTRU
    		movwf flag			    ;(for EEPROM and CFG cases)		
    	rcall Receive			    ;Hi
    	movwf TBLPTRH
    		movwf NVMADR      	;(for EEPROM case) * was EEADR		
    	rcall Receive			    ;Lo
    	movwf TBLPTRL
    		movwf NVMDAT		    ;(for EEPROM case) * was EEDATA
    	rcall Receive			    ;count
    	movwf i
    	incf i
    	lfsr FSR0, (buffer-1)	
    rcvoct						      ;read 64+1 bytes
    		movwf TABLAT		    ;prepare for cfg; => store byte before crc
    	rcall Receive
    	movwf PREINC0
    	decfsz i
    	bra rcvoct	
    	tstfsz crc				    ;check crc
    	bra ziieroare
    		btfss flag,6		    ;is EEPROM data?
    		bra noeeprom
    		movlw b'00000100'	  ;Setup eeprom
    		rcall Write
    		bra waitwre
    noeeprom
    		btfss flag,7		    ;is CFG data?
    		bra noconfig
    		tblwt*				      ;write TABLAT(byte before crc) to TBLPTR***
    		movlw b'11000100'	  ;Setup cfg
    		rcall Write
    		bra waitwre
    noconfig
                        ;write
    eraseloop
    	movlw	b'10010100'		  ; Setup erase
    	rcall Write
    	TBLRD*-					      ; point to adr-1
    	
    writebigloop	
    	movlw 8					      ; 8groups
    	movwf counter_hi
    	lfsr FSR0,buffer
    writesloop
    	movlw 8					      ; 8bytes = 4instr
    	movwf counter_lo
    writebyte
    	movf POSTINC0,w			  ; put 1 byte
    	movwf TABLAT
    	tblwt+*
    	decfsz counter_lo
    	bra writebyte
    	
    	movlw	b'10000100'		  ; Setup writes
    	rcall Write
    	decfsz counter_hi
    	bra writesloop
    waitwre	
    	;btfsc NVMCON1,WR		 ;for eeprom writes (wait to finish write)
    	;bra waitwre			   ;no need: round trip time with PC bigger than 4ms
    	
    	bcf NVMCON1,WREN		 ; Clears WREN bit to disable writes
    	bra MainLoop
    	
    ziieroare					     ;CRC failed
    	SendL 'N'
    	bra mainl
    	  
    ;******** procedures ******************
    
    Write ; See DS section11.1.2 for NVM Unlock Sequence instructions
    ;	BANKSEL NVMCON1         ; Bank to NVMCON1 register    
    ;  BSF     NVMCON1,WREN    ; Sets WREN bit to enable write/erase    
    ;  MOVLW   0x55            ; Load 55h    
    ;  MOVWF   NVMCON2         ; Step 1: Load 55h into NVMCON2    
    ;  MOVLW   0xAA            ; Step 2: Load W with AAh    
    ;  MOVWF   NVMCON2         ; Step 3: Load AAh into NVMCON2    
    ;  BSF     NVMCON1,WR      ; Step 4: Set WR bit to begin write/erase
    ;  NOP
    ;  RETURN
    
      movwf NVMCON1        ; Was movwf EECON1
    	movlw 0x55
    	movwf NVMCON2        ; Was EECON2
    	movlw 0xAA
    	movwf NVMCON2        ; Was EECON2
    	bsf NVMCON1,WR			 ; WRITE	
    	nop
    	;nop
    	return
    
    Receive	
      movlw xtal/1000000+1	; for 20MHz => 11 => 1second delay							
      movwf cnt1
    rpt2						
    	clrf cnt2
    rpt3
    	clrf cnt3		
    rptc
      btfss PIR3,RC1IF			;test RX  (was PIR1,RCIF)		
      bra notrcv
        movf RC1REG,w			  ;return read data in W
        addwf crc,f				  ;compute crc
      RETURN
    		
    notrcv
    	decfsz cnt3
    	bra rptc
    	decfsz cnt2
    	bra rpt3
    	decfsz cnt1
    	bra rpt2
    	
    ;timeout:
    way_to_exit;  
    	bcf	RC1STA,	SPEN			; deactivate UART (was RCSTA)
    	bra first_address
    
    ;*************************************************************
    ; After reset
    ; Do not expect the memory to be zero,
    ; Do not expect registers to be initialised like in catalog.
    
                END

    The tinybldWin program shows a good "Flashwrite":
    Code:
    ; tinyblWin log details capture
    
     
    Trying to connect to: COM30 
    Com parameters: 8 N 0 False False
    Connected to \\.\COM30 at 19200
       HEX: 3 min old, INHX32,18Fcode+cfg, total=284 bytes. 
      Searching for PIC ...
    Wait 350 ms
    Rcv:type=C6h="" 
    pic.BytesPerInstrPC=2  pic.BytesPerInstrPIC=2  pic.AddrIncrementPIC=2
    StartBldZone=1FEF8  SizeOfBLDBytesPC=264
       Found:PIC18F27K40
       Reading HEX file... 
    Also found:
    EEprom: __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
            __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
    Config: __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 
    
    
    Prepare18FPre - Check HEX and GOTO
      Reallocate RESET to [1FEF8h..1FEFFh] (byte addr)
    Prepare18FAfter - 0>Goto 1FF00,  Writing flash...
     Addr(bytes)=000000h,  4+128+1 bytes:
       Hex: 00 00 00 80 80 EF FF F0 05 6A 04 6E E8 6A 04 06 05 5A D8 A0 1A EF 00 F0 
            03 0E 03 6E E6 0E 02 D8 F5 D7 03 6A FB 0F 02 6E 00 D0 E8 6A 01 D0 02 06 
            03 5A FD E2 00 00 12 00 00 01 00 00 12 00 7D 0E E9 6E 0E 0E EA 6E ED 6A 
            E9 50 EA 10 FC E1 EF 6A 8D 6A 88 6A 0F 01 10 6B 0F 6B 0E 6B 0D 6B 8E 6A 
            C1 0E 89 6E 18 6B 17 6B 16 6B 15 6B 8F 6A A8 0E 8A 6E 20 6B 1F 6B 1E 6B 
            1D 6B 60 90 11 6B 19 6B 21 6B 39 9F DC    Str:
          Sent count: 185
          wait for a byte max 500 ms
       Received "K": Ok
    
     Addr(bytes)=000080h,  4+128+1 bytes:
       Hex: 00 00 80 80 35 9F AC 9E A8 9E 44 9F 33 9F 31 6B 32 9F A5 9E A2 9E 96 9A 
            0E 01 C2 89 0F 01 28 87 29 87 0E 01 7E 0E E1 6F FE 0E E2 6F E3 69 E4 69 
            3F 0E E5 6F E6 69 13 0E B5 6F 15 0E 8D 6F 09 0E F9 6F 0B 0E FB 6F A0 81 
            00 01 90 0E 9D 6E 20 0E 9E 6E 33 0E 9B 6E 9C 6A 9F 86 0E 01 90 0E 9D 6F 
            20 0E 9E 6F 33 0E 9B 6F 9C 6B 9F 87 40 0E 29 6E 83 92 83 90 84 98 84 86 
            84 82 84 84 31 6A 8F 8E 64 0E 00 01 75    Str:
          Sent count: 185
          wait for a byte max 500 ms
       Received "K": Ok
    
     Addr(bytes)=000100h,  4+128+1 bytes:
       Hex: 00 01 00 80 81 DF 83 72 7E 92 64 0E 7D DF FB D7 03 00 FE D7 FF FF FF FF 
            FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
            FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
            FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
            FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
            FF FF FF FF FF FF FF FF FF FF FF FF 12    Str:
          Sent count: 185
          wait for a byte max 500 ms
       Received "K": Ok
    
     Addr(bytes)=01FE80h,  4+128+1 bytes:
       Hex: 01 FE 80 80 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
            FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
            FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
            FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
            FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
            FF FF FF FF 1D EF 00 F0 05 6A 04 6E 9C    Str:
            
            
          Sent count: 185
          wait for a byte max 500 ms
       Received "K": Ok
    
     Flashwrite ok
       WRITE OK  at 9:42,   time:0.444 sec
    Disconnecting...
    OK
    The problem is that the bootloader only writes every other 64 bytes of the program and leaves 64 bytes of blanks within the final load.
    Here's the program memory read without bootloader:
    Code:
    0000- ef1d f000 6a05 6e04 6ae8 0604 5a05 a0d8 
    0010- ef1a f000 0e03 6e03 0ee6 d802 d7f5 6a03 
    0020- 0ffb 6e02 d000 6ae8 d001 0602 5a03 e2fd 
    0030- 0000 0012 0100 0000 0012 0e7d 6ee9 0e0e 
    0040- 6eea 6aed 50e9 10ea e1fc 6aef 6a8d 6a88 
    0050- 010f 6b10 6b0f 6b0e 6b0d 6a8e 0ec1 6e89 
    0060- 6b18 6b17 6b16 6b15 6a8f 0ea8 6e8a 6b20 
    0070- 6b1f 6b1e 6b1d 9060 6b11 6b19 6b21 9f39 
    0080- 9f35 9eac 9ea8 9f44 9f33 6b31 9f32 9ea5 
    0090- 9ea2 9a96 010e 89c2 010f 8728 8729 010e 
    00a0- 0e7e 6fe1 0efe 6fe2 69e3 69e4 0e3f 6fe5 
    00b0- 69e6 0e13 6fb5 0e15 6f8d 0e09 6ff9 0e0b 
    00c0- 6ffb 81a0 0100 0e90 6e9d 0e20 6e9e 0e33 
    00d0- 6e9b 6a9c 869f 010e 0e90 6f9d 0e20 6f9e 
    00e0- 0e33 6f9b 6b9c 879f 0e40 6e29 9283 9083 
    00f0- 9884 8684 8284 8484 6a31 8e8f 0e64 0100 
    0100- df81 7283 927e 0e64 df7d d7fb 0003 d7fe
    Same program with tiny bootloader installed and writing the program:
    Code:
    0000- ef80 f0ff 6a05 6e04 6ae8 0604 5a05 a0d8 
    0010- ef1a f000 0e03 6e03 0ee6 d802 d7f5 6a03 
    0020- 0ffb 6e02 d000 6ae8 d001 0602 5a03 e2fd 
    0030- 0000 0012 0100 0000 0012 0e7d 6ee9 0e0e 
    0040- ffff ffff ffff ffff ffff ffff ffff ffff 
    0050- ffff ffff ffff ffff ffff ffff ffff ffff 
    0060- ffff ffff ffff ffff ffff ffff ffff ffff 
    0070- ffff ffff ffff ffff ffff ffff ffff ffff 
    0080- 9f35 9eac 9ea8 9f44 9f33 6b31 9f32 9ea5 
    0090- 9ea2 9a96 010e 89c2 010f 8728 8729 010e 
    00a0- 0e7e 6fe1 0efe 6fe2 69e3 69e4 0e3f 6fe5 
    00b0- 69e6 0e13 6fb5 0e15 6f8d 0e09 6ff9 0e0b 
    00c0- ffff ffff ffff ffff ffff ffff ffff ffff 
    00d0- ffff ffff ffff ffff ffff ffff ffff ffff 
    00e0- ffff ffff ffff ffff ffff ffff ffff ffff 
    00f0- ffff ffff ffff ffff ffff ffff ffff ffff 
    0100- df81 7283 927e 0e64 df7d d7fb 0003 d7fe 
    0110- ffff ffff ffff ffff ffff ffff ffff ffff
    .
    .
    . I truncated file here of all ffff, too large
    .
    .
    1fef0- ffff ffff ffff ffff ffff ffff ffff ffff 
    1ff00- 0000 0000 0000 0000 010f 0e00 6f21 010e 
    1ff10- 0e13 6fb5 010e 0e09 6ff9 0e90 6e9d 0e20 
    1ff20- 6e9e 0e33 6e9b 0e00 6e9c 0e08 6e9f d846 
    1ff30- 08c1 e153 0ec6 6e9a 0e4b 6e9a 6a00 d83e 
    1ff40- 6ef8 6e07 d83b 6ef7 6e7e d838 6ef6 6e80 
    1ff50- d835 6e01 2a01 ee00 f009 6ef5 d82f 6eec 
    1ff60- 2e01 d7fb 6600 d01f ac07 d003 0e04 d81e 
    1ff70- d018 ae07 d004 000c 0ec4 d818 d012 0e94 
    1ff80- d815 000a 0e08 6e05 ee00 f00a 0e08 6e06 
    1ff90- 50ee 6ef5 000f 2e06 d7fb 0e84 d807 2e05 
    1ffa0- d7f5 9481 d7c9 0e4e 6e9a d7c8 6e81 0e55 
    1ffb0- 6e82 0eaa 6e82 8281 0000 0012 0e15 6e02 
    1ffc0- 6a03 6a04 abcd d003 5099 2600 0012 2e04 
    1ffd0- d7f9 2e03 d7f6 2e02 d7f3 9e9d d791 ffff 
    1ffe0- ffff ffff ffff ffff ffff ffff ffff ffff 
    1fff0- ffff ffff ffff ffff ffff ffff ffff ffff
    Since the PIC was not listed in the piccodes.ini file, I found the closest match ($C6) to work with and tried different combinations of value settings that would cause a failed write but never affected the way program gets loaded:
    Code:
    ; "K" have different write page each;  flash:8,16,32,64,+
    ; Flash sizes Kwords: 4/8/16/32
    ;C0,C1: 4KW
    ;C2,C3: 8KW
    $C2, K, 18K w/16KB F,      $4000, $100, 32, 32, 1, 3, 4, 0,
    ;                                       \EraseBlkI = 32words = 64B for small K
    ;                                           \ProgramBlk(Row)I = depends on PIC, can be 4/8/16/32words (8/16/32/64bytes)
    ;                                            ^  ^ make the product of those two be 32
    ;                            ^ from PDF ProgramMemoryMap
    ; those with write page larger than write page probably should have `erase_first` flag
    ;       PIC18F67K22:  send:128bytes  bld=2*64+4 instr (erase page the same as write page)
    ;
    ; Modified for 18F27K40, was: $C6, K, 18K w/128KB Flash, $20000, $100, 64, 64, 1, 8, 4, 0,
    $C6, K, PIC18F27K40,  $20000, $400, 64,32,2, 2, 4, 0,
    My circuit and final program work just fine and wanted to introduce the boot loader as the final feature but...
    I have attached the serial portion of the schematic if it helps.
    Serial I-O.pdf

    Sorry for the long post, just trying to be thorough...

    Thanks
    Louie

  • #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,199

    Default Re: Tiny Bootloader and PIC18F27K40

    Louie, Attached is a file that has been modified to be used with the MicroCode Loader. That way you can just work inside if MicroCode Studio. There are 2 different versions. The first is for com channel 1 (PortC.6.7) and one for com channel 2 (PortB.6.7. Just flash either one into the chip and use MicroCode Loader. Also you can NOT reassign the hardware USART ports as you like, Only use C.6.7 or B.6.7. I don't believe you can reassign the ports using the PPS module but what do I know? I have never tried it.
    Attached Files Attached Files
    Last edited by Dave; - 6th September 2019 at 18:26.
    Dave Purola,
    N8NTA
    EN82fn

  • #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    230

    Default Re: Tiny Bootloader and PIC18F27K40

    Thanks for the files Dave.
    I don't think I've used MicroCode Loader before but will check it out.
    Louie

  • #4
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    230

    Default Re: Tiny Bootloader and PIC18F27K40

    Dave,

    I don't have MicroCode Loader in my arsenal so I ordered it so I can experiment. It's a few bucks and will probably come in handy even if it doesn't for this chip.

    This PIC needs to have the EUSART pins assigned. The only default is RX1 to RC7.
    But I'm willing to arm wrestle it until I get some Tiny Bootloader insight.

    Thanks again...

    Name:  PIC18F27K40 pins.PNG
Views: 103
Size:  169.1 KB
    Louie

  • #5

    Default Re: Tiny Bootloader and PIC18F27K40

    Code:
    ; Modified for 18F27K40, was: $C6, K, 18K w/128KB Flash, $20000, $100, 64, 64, 1, 8, 4, 0,
    $C6, K, PIC18F27K40,  $20000, $400, 64,32,2, 2, 4, 0,
    I'm not familiar with the settings for tiny, but the 27K40 has 128 byte erase and program block sizes.
    Are you sure those match?

  • #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,199

    Default Re: Tiny Bootloader and PIC18F27K40

    Tumbleweed, Here are the .ASM files I assembled for the .HEX files.
    Attached Files Attached Files
    Dave Purola,
    N8NTA
    EN82fn

  • #7
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    230

    Default Re: Tiny Bootloader and PIC18F27K40

    tumbleweed: I recall trying 128 byte settings once but could've had something else misconfigured at the same time.
    I'll start from there, thanks for verifying block sizes.

    Dave: Thanks for the asm files. I received the MicroCode Loader this morning from across the pond Dave.
    I'm going to experiment with the Tiny terminal timing this morning for a bit before jumping into these new file you provided.
    Louie

  • #8
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    230

    Default Re: It's working with MC Loader!

    I spent so much time trying to get the tiny bootloader to work it felt like a big disappointment and waste of time. But as it turns out, the experience fumbling with the asm code made me more confident to alter the 27K40_2COM1.asm file Dave provided to work with the circuit I have already built.

    I was able to reassign the pins as needed because the PPS commands were already there and just have to change their to and fros.
    Code:
    ; the following assumes using uart1 with PORTC RC2(TX output) and RC3(RX input) pins
    #define TX_PIN_   2		; MOD 9/7/2019
    #define RX_PIN_   3		; MOD 9/7/2019
    #define PPSLOCKED_ 0  ; PPSLOCK bit 0
    #define GIE_  7       ; INTCON bit 7
    and here
    Code:
      ; EUSART #1	MOD 9/7/2019  
       ; set PORTC to digital mode
       Banksel ANSELC
       movlw b'00000000'		
       movwf ANSELC
       
       ; set normal slewrate for RC2/RC3 (SLRCx = 0)
       banksel SLRCONC
       bcf SLRCONC, RX_PIN_        ; RC2/TX
       bcf SLRCONC, TX_PIN_        ; RC3/RX
       
       ; set uart TX and RX pin directions (these will over-ridden by the usart as req'd)
       banksel TRISC
       bcf TRISC, TX_PIN_         ; RC2/TX output
       bsf TRISC, RX_PIN_         ; RC3/RX input
    
       ; assign pps
       ; first, make sure PPSLOCK is unlocked (just in case)
       bcf  INTCON, GIE_
       banksel  PPSLOCK
       movlw  0x55
       movwf  PPSLOCK
       movlw  0xAA
       movwf  PPSLOCK
       bcf    PPSLOCK, PPSLOCKED_
       
       ; now assign uart1 pps pins
       movlw  0x13        ; RX1PPS=0x13 - select PORTC<3> as EUSART1 RX input
       movwf  RX1PPS
       movlw  0x09        ; RC2PPS=0x09 - select PORTC<6> as EUSART1 TX output
       movwf  RC2PPS
    
       ; now assign uart2 pps pins
       movlw  0x15        ; RX2PPS=0x15 - select PORTC<5> as EUSART2 RX input
       movwf  RX2PPS
       movlw  0x0B        ; RC4PPS=0x0B - select PORTC<4> as EUSART2 TX output
       movwf  RC4PPS
    
       banksel 0
       endm
    Problems encountered when trying to use:
    1. Rushed into trying to program with MicroCode Loader before reading directions. Needed "DEFINE LOADER_USED 1" in my program.
    2. Default OSC was 64MHz, set to 16MHz
    3. Small test program loaded and worked easy peasy but my 13k byte program always failed write at different memory locations. Used Docklight Pro Monitor to watch the process and found that it was a hardware issue that went away when the board was flexed a little. Need to fix that.

    Bottom line it's working! Much thanks for your help.

    Here's the modded asm file for those interested.
    27K40_UART1.asm.txt
    Louie

  • #9
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,199

    Default Re: It's working with MC Loader!

    Louie, Glad you got it working. I forgot to tell you about the "DEFINE LOADER_USED 1" command when using a boot loader with PBP. After posting you the .ASM file I got to thinking about the PPS module and it makes sense that you can alter the I/O ports for the USART. Great job....
    Dave Purola,
    N8NTA
    EN82fn

  • #10
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    230

    Default Update

    Thanks Dave,

    Took a break to do some mind relaxing yard work and had that "Ah ha!" moment. Realized that I neglected to enable the RS232 chip, SN65C3222E within the bootloader.
    I chose this one so I can shut everything down for super low Sleep mode current.

    Since PORTB defaults to analog, the two enable pins were just floating and the RS232 chip happen to work most of the time but NOT long enough for the large file.

    Now added these to make sure my gateway to the outside world are really open for business and the large file load is consistent. Silly me.
    Code:
    #define Ser_TX_En_  3       ; MOD 9/8/2019 RB3: SN65C3222E TX enable pin
    #define Ser_RX_En_  4       ; MOD 9/8/2019 RB4: SN65C3222E RX enable pin
    .
    .
    .
    ;*************** Enable external RS232 SN65C3222E chip ****************
       ; set Ser_TX_En and Ser_RX_En pins to digital mode (ANB3, ANB4 = 0)
       banksel ANSELB
       bcf ANSELB, Ser_TX_En_        ; RB3/Serial TX enable
       bcf ANSELB, Ser_RX_En_        ; RB4/Serial RX enable
    
       ; set Serial TX and RX enable pin directions
       banksel TRISB
       bcf TRISB, Ser_TX_En_        ; Set RB3 to output
       bcf TRISB, Ser_RX_En_        ; Set RB4 to output
       bsf LATB,  Ser_TX_En_        ; RB3 = 1
       bcf LATB,  Ser_RX_En_        ; RB4 = 0
    ; *******************************************************************
    I'm still not giving up on the Tiny bootloader though.
    Since the MicroCode is based on it, I hope to find the cure for the "half writes" by comparing the two.

    One more thing.
    The last code attached was rushed to post and bogus, sorry. Here's the real one with the latest add on:
    Attached Files Attached Files
    Louie

  • #11
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,199

    Default Re: Update

    Thanks Louie, I appreciate the update..
    Dave Purola,
    N8NTA
    EN82fn

  • #12
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,915

    Default Re: Update

    Great job Louie!

    Ioannis

  • #13
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    230

    Default Re: Tiny Bootloader and PIC18F27K40

    Thanks Ioannis,

    I'm getting closer with the Tiny Bootloader. A couple little value changes to it writes the complete program now, but...
    it stays it the bootloader and won't run my program. The saga continues!
    Louie

  • #14
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    230

    Default PIC18FF27K40 with Tiny Bootloader Solved!

    Turns out I was using and old Tiny BL revision so I download the latest from here: Tiny Multi Bootloader+

    Short story version:
    So even after setting everything up like the last one, my downloaded program still wouldn't run!

    Solution:
    Changed the bootloader size to match what is listed in the piccodes.ini file.

    Part of Bootloader asm program
    Code:
    #define first_address max_flash-264		;adjust to Bootloader size
    part of piccodes.ini file
    Code:
    $6F, C, 18F w/128KB flash & 1024B EEPROM, $20000, $400, 264, 128,
    Then out of curiosity, I compared the non working(256 size) to working(264 size) Bootloader + memory files and all the data was there except the working one is shifted up some.
    A closer look and can see that it was the 4 empty Words preceding the bootloader program that contains the reset Goto, ahhhhhh.
    Location, location, location!
    Code:
    Bootloader size set to 256:
    
    0000- ef80 f0ff ffff ffff 6a05 6e04 6ae8 0604 
    0010- 5a05 a0d8 ef1c f000 0e03 6e03 0ee6 d802 
    0020- d7f5 6a03 0ffb 6e02 d000 6ae8 d001 0602 
    0030- 5a03 e2fd 0000 0012 0100 0000 0012 0e7d 
    0040- 6ee9 0e0e 6eea 6aed 50e9 10ea e1fc 6aef 
    0050- 6a8d 6a88 010f 6b10 6b0f 6b0e 6b0d 6a8e 
    0060- 0ec1 6e89 6b18 6b17 6b16 6b15 6a8f 0ea8 
    0070- 6e8a 6b20 6b1f 6b1e 6b1d 9060 6b11 6b19 
    0080- 6b21 9f39 9f35 9eac 9ea8 9f44 9f33 6b31 
    0090- 9f32 9ea5 9ea2 9a96 010e 89c2 010f 8728 
    00a0- 8729 010e 0e7e 6fe1 0efe 6fe2 69e3 69e4 
    00b0- 0e3f 6fe5 69e6 0e13 6fb5 0e15 6f8d 0e09 
    00c0- 6ff9 0e0b 6ffb 81a0 0100 0e90 6e9d 0e20 
    00d0- 6e9e 0e33 6e9b 6a9c 869f 010e 0e90 6f9d 
    00e0- 0e20 6f9e 0e33 6f9b 6b9c 879f 0e40 6e29 
    00f0- 9283 9083 9884 8684 8284 8484 6a31 8e8f 
    0100- 0e64 0100 df81 7283 927e 0e01 6e05 0ef4 
    0110- df7c d7f9 0003 d7fe ffff ffff ffff ffff 
    0120- ffff ffff ffff ffff ffff ffff ffff ffff
    .
    .
    .
    1fee0- ffff ffff ffff ffff ffff ffff ffff ffff 
    1fef0- ffff ffff ffff ffff ef1f f000 ffff ffff <------- Reset Goto written by bootloader
    1ff00- 0000 0000 0000 0000 010f 9719 9919 010f 
    1ff10- 9689 9889 8684 9884 010f 0e00 6f21 010e 
    1ff20- 0e13 6fb5 010e 0e09 6ff9 0e90 6e9d 0e20 
    1ff30- 6e9e 0e33 6e9b 0e00 6e9c 0e08 6e9f d842 
    1ff40- 08c1 e14f 0e6f 6e9a 0e4b 6e9a 6a00 d83a 
    1ff50- 6ef8 6e7f d837 6ef7 6e7e d834 6ef6 6e80 
    1ff60- d831 6e01 2a01 ee00 f009 6ef5 d82b 6eec 
    1ff70- a001 6e80 2e01 d7f9 6600 d019 ac7f d003 
    1ff80- 0e04 d818 d012 0e94 d815 000a 0e10 6e05 
    1ff90- ee00 f00a 0e08 6e06 50ee 6ef5 000f 2e06 
    1ffa0- d7fb 0e84 d807 2e05 d7f5 9481 d7cd 0e4e 
    1ffb0- 6e9a d7cc 6e81 0e55 6e82 0eaa 6e82 8281 
    1ffc0- 0000 0012 0e0b 6e02 6a03 6a04 abcd d003 
    1ffd0- 5099 2600 0012 2e04 d7f9 2e03 d7f6 2e02 
    1ffe0- d7f3 9e9d d78d ffff ffff ffff ffff ffff 
    1fff0- ffff ffff ffff ffff ffff ffff ffff ffff
    Code:
    Bootloader size set to 264:
    
    0000- ef80 f0ff ffff ffff 6a05 6e04 6ae8 0604 
    0010- 5a05 a0d8 ef1c f000 0e03 6e03 0ee6 d802 
    0020- d7f5 6a03 0ffb 6e02 d000 6ae8 d001 0602 
    0030- 5a03 e2fd 0000 0012 0100 0000 0012 0e7d 
    0040- 6ee9 0e0e 6eea 6aed 50e9 10ea e1fc 6aef 
    0050- 6a8d 6a88 010f 6b10 6b0f 6b0e 6b0d 6a8e 
    0060- 0ec1 6e89 6b18 6b17 6b16 6b15 6a8f 0ea8 
    0070- 6e8a 6b20 6b1f 6b1e 6b1d 9060 6b11 6b19 
    0080- 6b21 9f39 9f35 9eac 9ea8 9f44 9f33 6b31 
    0090- 9f32 9ea5 9ea2 9a96 010e 89c2 010f 8728 
    00a0- 8729 010e 0e7e 6fe1 0efe 6fe2 69e3 69e4 
    00b0- 0e3f 6fe5 69e6 0e13 6fb5 0e15 6f8d 0e09 
    00c0- 6ff9 0e0b 6ffb 81a0 0100 0e90 6e9d 0e20 
    00d0- 6e9e 0e33 6e9b 6a9c 869f 010e 0e90 6f9d 
    00e0- 0e20 6f9e 0e33 6f9b 6b9c 879f 0e40 6e29 
    00f0- 9283 9083 9884 8684 8284 8484 6a31 8e8f 
    0100- 0e64 0100 df81 7283 927e 0e01 6e05 0ef4 
    0110- df7c d7f9 0003 d7fe ffff ffff ffff ffff 
    0120- ffff ffff ffff ffff ffff ffff ffff ffff
    .
    .
    .
    1fee0- ffff ffff ffff ffff ffff ffff ffff ffff 
    1fef0- ffff ffff ffff ffff ef1f f000 ffff ffff <------- Reset Goto written by bootloader 
    1ff00- 010f 9719 9919 010f 9689 9889 8684 9884 
    1ff10- 010f 0e00 6f21 010e 0e13 6fb5 010e 0e09 
    1ff20- 6ff9 0e90 6e9d 0e20 6e9e 0e33 6e9b 0e00 
    1ff30- 6e9c 0e08 6e9f d842 08c1 e14f 0e6f 6e9a 
    1ff40- 0e4b 6e9a 6a00 d83a 6ef8 6e7f d837 6ef7 
    1ff50- 6e7e d834 6ef6 6e80 d831 6e01 2a01 ee00 
    1ff60- f009 6ef5 d82b 6eec a001 6e80 2e01 d7f9 
    1ff70- 6600 d019 ac7f d003 0e04 d818 d012 0e94 
    1ff80- d815 000a 0e10 6e05 ee00 f00a 0e08 6e06 
    1ff90- 50ee 6ef5 000f 2e06 d7fb 0e84 d807 2e05 
    1ffa0- d7f5 9481 d7cd 0e4e 6e9a d7cc 6e81 0e55 
    1ffb0- 6e82 0eaa 6e82 8281 0000 0012 0e0b 6e02 
    1ffc0- 6a03 6a04 abcd d003 5099 2600 0012 2e04 
    1ffd0- d7f9 2e03 d7f6 2e02 d7f3 9e9d d78d ffff 
    1ffe0- ffff ffff ffff ffff ffff ffff ffff ffff 
    1fff0- ffff ffff ffff ffff ffff ffff ffff ffff
    Here's the working copy:
    Attached Files Attached Files
    Louie

  • Similar Threads

    1. test tiny bootloader via bluetooth
      By hatuan291 in forum mel PIC BASIC Pro
      Replies: 1
      Last Post: - 13th September 2015, 13:35
    2. Replies: 1
      Last Post: - 2nd September 2014, 20:57
    3. I2C clock code with tiny problem
      By Amoque in forum mel PIC BASIC Pro
      Replies: 7
      Last Post: - 27th October 2013, 00:36
    4. Tiny Bootloader 18F2420
      By ultiblade in forum mel PIC BASIC Pro
      Replies: 11
      Last Post: - 31st March 2010, 17:32
    5. Tiny bootloader and 18F4525
      By Najim in forum Off Topic
      Replies: 1
      Last Post: - 11th January 2006, 11:43

    Members who have read this thread : 13

    You do not have permission to view the list of names.

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts