blueroomelectronics
Well-Known Member
This program is designed to set the VDD calibration data (it's erased when you name the Junebug with the PICkit2 software)
A calibrated Junebug can program 3.3V PICs that have 5V tolerant I/O like the 18F67J60 (target must have its own 3.3V power supply)
You use the Junebugs bootloader feature to install the hex file this program creates (hold down the button near pin1 on the 18F2550) before plugging in the USB cable.
After it runs (about 2 sec) unplug the Junebug, close PICkit2 2.50 and hold down the bootloader button and plug in the USB cable. Reload PICkit2 2.50
and install the PICkit2 OS.
This program is in testing at this point, do not change anything unless you understand how the PICkit2 bootloader function.
A calibrated Junebug can program 3.3V PICs that have 5V tolerant I/O like the 18F67J60 (target must have its own 3.3V power supply)
You use the Junebugs bootloader feature to install the hex file this program creates (hold down the button near pin1 on the 18F2550) before plugging in the USB cable.
After it runs (about 2 sec) unplug the Junebug, close PICkit2 2.50 and hold down the bootloader button and plug in the USB cable. Reload PICkit2 2.50
and install the PICkit2 OS.
This program is in testing at this point, do not change anything unless you understand how the PICkit2 bootloader function.
Code:
; Change only the data in the two following defines
#define MyJune "Super Junebug" ; Junebug name <= 15 bytes
#define VCal 0xFA81 ; 4.2V Calibration 0x02
list p=18F2550
include <p18F2550.inc>
org 0x2000 ; Junebug bootloader vector
Start clrf INTCON ; interrupts OFF
movlw low(Name)
movwf TBLPTRL
movlw high(Name)
movwf TBLPTRH ; point to Name table
movlw 0xF0 ; EEPROM Name address
movwf EEADR
clrf EECON1
movlw '#' ;
rcall WriteEE
Loop tblrd*+ ; read table and increment
movf EEADR,W
bz WR_VCal
movf TABLAT,W ; W = TABLAT
rcall WriteEE
bra Loop
WR_VCal clrf EEADR ; 0x00 0101FA81
movlw 0x01
rcall WriteEE
movlw 0x01
rcall WriteEE
movlw high(VCal)
rcall WriteEE
movlw low(VCal)
rcall WriteEE
bcf TRISC,0 ; busy LED
Flash clrwdt
decfsz WREG
bra $-2
btg LATC,0 ; flash busy LED
bra Flash ;
Name data MyJune
data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;padding
; enter W = Data, will auto increment EEADR
WriteEE bcf PIR2,EEIF ; clear EE flag
clrwdt
movwf EEDATA ; EEDATA = W
bsf EECON1,WREN ; enable EEPROM writes
movlw 0x55
movwf EECON2
movlw 0xAA
movwf EECON2
bsf EECON1,WR
nop
btfss PIR2,EEIF
bra $-2
bcf EECON1,WREN
incf EEADR
return
END