----- Original Message ----- From: Jess Hancock To: Sent: Wednesday, February 28, 2001 12:26 AM Subject: How2 erase/modify/reprogram 12c671 > Hi > > This is my first PIC project - the code was written by someone else and > I'm just trying to duplicate it. > Therefore, I need to modify the hex or asm code to include a routine to > program the correct calibration value into the OSCCAL register. The initial > code for the program begins at 0000h and is listed below - I hope its > readable. (The MPLAB disassembler prefixes memory locations with "ad". > > ; > ORG 0000h > ; > MOVLW 0x00 ;original code > MOVWF PCLATH > GOTO ad007F > ; > > The program code ends with the following: > > ad00CE CLRF 0x24 > BSF STATUS,RP0 > BCF GPIO,3 ; ??? RAM Page TRISIO,3 > BCF STATUS,RP0 > BCF GPIO,3 ; ??? RAM Page TRISIO,3 > ; > ad00D3 GOTO ad0094 > ; > SLEEP ; (This is apparently never called) > ; > ORG 03FFh > ; > RETLW 0x88 ; (This is not the correct value for > my 671) > > Will the following patch work or is there a better way? > Thanks in advance. Jess > > 0000 GOTO 00D6 > . > . > . > 00D6 CLRF GPIO ;not sure if this is required > CALL 0X3FF ; RETLW with OSCCAL at 0x03FF > BSF STATUS,RP0 ;BANK 1 > MOVWF OSCCAL > BCF STATUS,RP0 ;BANK 0 > ; > MOVLW 0x00 ;relocated original code from 0000h starts here > MOVWF PCLATH > GOTO 007Fh ;Go continue with remainder of program > ; > ORG 03FFh > RETLW 0x40 ;The correct calibration value Jess, you have the right idea, but you should be sure that PCLATH is clear before you do anything else. I'd use: org 0x0 movlw 0 movwf PCLATH goto 0xD6 org 0xD6 call 0X3FF ; get osccal value bsf STATUS,RP0 movwf OSCCAL bcf STATUS,RP0 movlw 0 goto 0x7F Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) ORG 0x02 > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. > > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.