electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

PIC16F84 Hex reverse engineering for PIC16F628


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> PIC16F84 Hex reverse engineering for PIC16F628
Author Message
glenjoy



Joined: 01 Jan 2004
Posts: 1028
Helped: 47
Location: Philippines


Post09 Aug 2005 18:56   

windis84


I have this PIC16F84 code in hex, now I want to use PIC16F628 so I can avoid the crystal oscillator.

Is there a possiblity to do this?

Thanks.
Back to top
Google
AdSense
Google Adsense




Post09 Aug 2005 18:56   

Ads




Back to top
Jack// ani



Joined: 02 Dec 2004
Posts: 488
Helped: 25


Post09 Aug 2005 19:35   

pic16f84 disassembler


You mean to say you want to use internal osc of 16f628, am I right??
Back to top
glenjoy



Joined: 01 Jan 2004
Posts: 1028
Helped: 47
Location: Philippines


Post09 Aug 2005 20:12   

pic 16f628 disassembler


This is the code I want to convert,

Code:
; Generated by WinDis84, (c) Nigel Goodwin 1998.

            LIST      P=16F84, F=INHX8M
            include "P16FXX.inc"
            ORG     0x0000

            MOVLW   0x00
            MOVWF   PCLATH
            GOTO    Label_0001
            NOP
Label_0016  MOVLW   0x21
            MOVWF   FSR
            MOVF    INDF      , W
            BTFSC   STATUS    , Z
            GOTO    Label_0002
Label_0006  MOVLW   0x01
            MOVWF   0x0D
Label_0004  CLRF    0x0C
Label_0003  DECFSZ  0x0C      , f
            GOTO    Label_0003
            DECFSZ  0x0D      , f
            GOTO    Label_0004
            MOVLW   0x4A
            MOVWF   0x0C
Label_0005  DECFSZ  0x0C      , f
            GOTO    Label_0005
            NOP
            NOP
            DECFSZ  INDF      , f
            GOTO    Label_0006
Label_0002  RETLW   0x00
Label_0018  MOVLW   0x08
            MOVWF   0x0C
            BSF     STATUS    , RP0
            BSF     TRISB     , 04
            BCF     STATUS    , RP0
Label_0007  BTFSC   PORTB     , 04
            GOTO    Label_0007
            CLRF    0x21
            BSF     0x0C      , 07
            GOTO    Label_0008
Label_000C  BCF     0x0C      , 07
            GOTO    Label_0008
Label_0009  BCF     STATUS    , C
            RRF     0x21      , f
            BTFSC   PORTB     , 04
            BSF     0x21      , 07
            BSF     0x0C      , 06
            GOTO    Label_0008
Label_000D  BCF     0x0C      , 06
            DECFSZ  0x0C      , f
            GOTO    Label_0009
            BSF     0x0C      , 05
            GOTO    Label_0008
Label_000E  BCF     0x0C      , 05
            MOVF    0x21      , W
            MOVWF   0x0D
            GOTO    Label_000A
Label_0008  MOVLW   0x1C
            BTFSC   0x0C      , 07
            MOVLW   0x07
            MOVWF   0x0D
Label_000B  DECFSZ  0x0D      , f
            GOTO    Label_000B
            NOP
            BTFSC   0x0C      , 07
            GOTO    Label_000C
            BTFSC   0x0C      , 06
            GOTO    Label_000D
            BTFSC   0x0C      , 05
            GOTO    Label_000E
            GOTO    Label_0009
Label_000A  RETLW   0x00
Label_0025  CLRF    0x23
            BSF     STATUS    , RP0
            BCF     TRISB     , 05
            BCF     STATUS    , RP0
            BCF     PORTB     , 05
            MOVLW   0x08
            MOVWF   0x0D
            NOP
            NOP
            NOP
            BSF     0x0D      , 07
            GOTO    Label_000F
Label_0012  BCF     0x0D      , 07
Label_0010  MOVF    0x22      , W
            XORWF   0x23      , f
            RRF     0x22      , f
            BTFSC   STATUS    , C
            BSF     PORTB     , 05
            BTFSS   STATUS    , C
            BCF     PORTB     , 05
            BSF     0x0D      , 06
            GOTO    Label_000F
Label_0013  BCF     0x0D      , 06
            DECFSZ  0x0D      , f
            GOTO    Label_0010
            NOP
            NOP
            NOP
            BTFSS   0x23      , 00
            BSF     PORTB     , 05
            BTFSC   0x23      , 00
            BCF     PORTB     , 05
            BSF     0x0D      , 05
            GOTO    Label_000F
Label_0014  BCF     0x0D      , 05
            BSF     PORTB     , 05
            GOTO    Label_000F
Label_000F  MOVLW   0x1C
            MOVWF   FSR
Label_0011  DECFSZ  FSR       , f
            GOTO    Label_0011
            NOP
            BTFSC   0x0D      , 07
            GOTO    Label_0012
            BTFSC   0x0D      , 06
            GOTO    Label_0013
            BTFSC   0x0D      , 05
            GOTO    Label_0014
            GOTO    Label_0015
Label_0001  CLRF    FSR
            MOVLW   0x1F
            ANDWF   STATUS    , f
            BSF     STATUS    , RP0
            BCF     TRISB     , 05
            BCF     STATUS    , RP0
            BSF     PORTB     , 05
            MOVLW   0x1F
            MOVWF   0x0E
            MOVLW   0x48
            MOVWF   0x0F
            CLRF    0x10
            MOVLW   0x4E
            MOVWF   0x11
            CLRF    0x12
            MOVLW   0x02
            MOVWF   0x13
            MOVLW   0x01
            MOVWF   0x14
            MOVLW   0x1F
            MOVWF   0x15
            CLRF    0x16
            MOVLW   0x48
            MOVWF   0x17
            MOVLW   0x7F
            MOVWF   0x18
            CLRF    0x19
            CLRF    0x1A
            CLRF    0x1B
            BSF     STATUS    , RP0
            BCF     TRISB     , 05
            BCF     STATUS    , RP0
            BSF     PORTB     , 05
            MOVLW   0x01
            MOVWF   0x21
            CALL    Label_0016
            BSF     PORTA     , 01
            BSF     STATUS    , RP0
            BCF     TRISA     , 01
            BCF     STATUS    , RP0
            BSF     PORTA     , 03
            BSF     STATUS    , RP0
            BCF     TRISA     , 03
            BCF     STATUS    , RP0
            BSF     PORTA     , 02
            BSF     STATUS    , RP0
            BCF     TRISA     , 02
            BCF     STATUS    , RP0
Label_0027  CLRF    0x1B
Label_001B  MOVLW   0x07
            SUBWF   0x1B      , W
            BTFSC   STATUS    , C
            GOTO    Label_0017
            CALL    Label_0018
            MOVF    0x0D      , W
            MOVWF   0x1C
            MOVLW   0x0E
            ADDWF   0x1B      , W
            MOVWF   FSR
            MOVF    INDF      , W
            SUBWF   0x1C      , W
            BTFSS   STATUS    , Z
            GOTO    Label_0019
            INCF    0x1B      , f
            GOTO    Label_001A
Label_0019  CLRF    0x1B
Label_001A  GOTO    Label_001B
Label_0017  CALL    Label_0018
            MOVF    0x0D      , W
            MOVWF   0x1D
            CALL    Label_0018
            MOVF    0x0D      , W
            MOVWF   0x1E
            CALL    Label_0018
            MOVF    0x0D      , W
            MOVWF   0x1F
            MOVLW   0x08
            MOVWF   0x21
            CALL    Label_0016
            MOVF    0x1D      , W
            ANDLW   0x01
            IORLW   0x00
            BTFSS   STATUS    , Z
            GOTO    Label_001C
            BCF     PORTA     , 01
            GOTO    Label_001D
Label_001C  BSF     PORTA     , 01
Label_001D  BSF     STATUS    , RP0
            BCF     TRISA     , 01
            BCF     STATUS    , RP0
            MOVF    0x1D      , W
            ANDLW   0x02
            IORLW   0x00
            BTFSS   STATUS    , Z
            GOTO    Label_001E
            BCF     PORTA     , 03
            GOTO    Label_001F
Label_001E  BSF     PORTA     , 03
Label_001F  BSF     STATUS    , RP0
            BCF     TRISA     , 03
            BCF     STATUS    , RP0
            MOVF    0x1D      , W
            ANDLW   0x04
            IORLW   0x00
            BTFSS   STATUS    , Z
            GOTO    Label_0020
            BCF     PORTA     , 02
            GOTO    Label_0021
Label_0020  BSF     PORTA     , 02
Label_0021  BSF     STATUS    , RP0
            BCF     TRISA     , 02
            BCF     STATUS    , RP0
            MOVF    0x1E      , W
            MOVWF   0x19
            CLRF    0x20
            CLRF    0x1B
Label_0023  MOVLW   0x05
            SUBWF   0x1B      , W
            BTFSC   STATUS    , C
            GOTO    Label_0022
            MOVLW   0x15
            ADDWF   0x1B      , W
            MOVWF   FSR
            MOVF    INDF      , W
            XORWF   0x20      , f
            INCF    0x1B      , f
            GOTO    Label_0023
Label_0022  MOVF    0x20      , W
            MOVWF   0x1A
            CLRF    0x1B
Label_0026  MOVLW   0x06
            SUBWF   0x1B      , W
            BTFSC   STATUS    , C
            GOTO    Label_0024
            MOVLW   0x15
            ADDWF   0x1B      , W
            MOVWF   FSR
            MOVF    INDF      , W
            MOVWF   0x21
            MOVWF   0x22
            GOTO    Label_0025
Label_0015  INCF    0x1B      , f
            GOTO    Label_0026
Label_0024  BSF     STATUS    , RP0
            BCF     TRISB     , 05
            BCF     STATUS    , RP0
            BSF     PORTB     , 05
            GOTO    Label_0027
            SLEEP
 
            ORG     0x2000
            DATA    0x0F
            DATA    0x0F
            DATA    0x0F
            DATA    0x0F
 
            ORG     0x2007
            DATA    0x19
 
            ORG     0x2100
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF
            DATA    0xFF

            END


This is from the site of http://www.atrox.at/datacable/.

I am think if there is a possibility to convert the code into PIC16F628 to avoid the crystal oscillator.

I already tried changing the configuration bits, it runs but very unstable.
Back to top
Mike, K8LH



Joined: 06 Jun 2005
Posts: 130
Helped: 16
Location: Michigan, USA


Post09 Aug 2005 21:14   

gsm alarm pic16f628


It seems they're running the 16F84 on an 8-MHz crystal oscillator... The 16F628/A only has a 4-MHz INTOSC... Also, the 16F84 does not have a built-in USART peripheral so they must be bit-banging the serial I/O...

I suspect you're looking for timing specific code in that hex file where they're developing the bit timing delays... You've got some work ahead of you...

Have you tried contacting the author for help? Perhaps he'd be willing to provide you with the source code...

Good luck with your project... Regards, Mike
Back to top
metal



Joined: 21 Dec 2004
Posts: 369
Helped: 13


Post09 Aug 2005 21:45   

migrating from 16f84 to 16f628


Hello

This is IC-Prog disassembling, I presume !?

Any way, open the hex file with IC-prog, modify the PIC16F628 fuses as you want, and save the as new hex file. Open it again, and burn the PIC with the newly modified file. It shall work now.

Good luck
Back to top
glenjoy



Joined: 01 Jan 2004
Posts: 1028
Helped: 47
Location: Philippines


Post10 Aug 2005 4:46   

reverse engineering hex


metal wrote:
Hello

This is IC-Prog disassembling, I presume !?

Any way, open the hex file with IC-prog, modify the PIC16F628 fuses as you want, and save the as new hex file. Open it again, and burn the PIC with the newly modified file. It shall work now.

Good luck


Have you tried doing it?

Because I tried it in IC-prog too, but did not saved it, just opened it, changed the fuses then burn.
Back to top
C-Man



Joined: 19 Jul 2001
Posts: 1235
Helped: 73


Post10 Aug 2005 5:30   

pic16f628 hex file


One problem with the 16F628 is that the comperator module is enabled by default Sad

So you will have to disable it inside your code otherwise the 4 comperator inputs are not useable as digital i/o.

best regards
Back to top
unhappy



Joined: 25 Jul 2005
Posts: 21


Post10 Aug 2005 16:40   

pic16f628 hex


There is also internal memory mapping problem as F84 is 1k whereas F628 is 2k
Back to top
metal



Joined: 21 Dec 2004
Posts: 369
Helped: 13


Post11 Aug 2005 8:28   

pic16f disassembler


Hello glenjoy

I have attached nice disassembler tools, hope you find them useful Smile



Sorry, but you need login in to view this attachment

Back to top
mzeitoun2002



Joined: 01 Mar 2005
Posts: 75
Helped: 1


Post16 Aug 2005 18:24   

pic16f84 to pic16f628


Salam,

Even if u changed the fuses selection by IC-PROG the analog I/P's of the comparator is still running u will have to readjust the assembled code so that at the beginning the CMCON register must equal 0X07 to disable the analog I/P's

Hope that helps
Back to top
Buriedcode



Joined: 06 May 2004
Posts: 327
Helped: 34
Location: London


Post18 Aug 2005 5:16   

pic16f628 disassembler


My two cents...

When I migrate from the F84, to any higher-end micros, I nearly always have to change the start of the variables registers (cblock, if used). The F84 I believe starts at 0x0C, but because many 'newer' micros have more peripherals, the have many more peripheral control registers. Hence, the genral purpose registers start at a higher address, say, 0x20.



Quote:
Label_0006 MOVLW 0x01
MOVWF 0x0D
Label_0004 CLRF 0x0C
Label_0003 DECFSZ 0x0C


Disassemblers never know the names people have given to registers, obviously, and here the addresses 0x0C, and 0x0D are used. Assuming these are used as general prupose registers in the original 16F84 context, in the 628, 0x0C is the 'PIR1' register, (peripheral interupt), and 0x0D is 'unimplemented'. Meaning, the program is inadvertantly changing the settings of the peripherals, and reading the registers wrong.

I would write a small piece of code to disable all the special features of the 628 (that the F84 doesn't have) and any file registers that are modified should have their addresses moved up. , by a minimum, of 14h (add 20 decimal).
ie: 0Ch -> 20h
0Dh -> 21h etc..

I don't know if you knew this already, or if it will solve your problem. Mike had a great point. If you want to convert it to run on 4Mhz, instead of 8, its gonna be tough.

Good Luck,

BuriedCode
Back to top
ximon



Joined: 12 Dec 2007
Posts: 7
Helped: 1


Post26 Dec 2007 14:02   

pic16f628 intosc


I know this is an old thread but i'm working on a gsm car alarm using an old 6310 and was wondering if anybody had successfully converted the 'f84 hex to run on the '628?
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> PIC16F84 Hex reverse engineering for PIC16F628
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
Frequency Counter for PIC16F84 or PIC16F628 (8)
This code [for PIC16F84] doesn't work with PIC16F628(A) ??!! (4)
sending HEX file to pic16f84 (3)
sending hex file to pic16f84 (1)
REVERSE engineering (17)
reverse engineering (7)
reverse engineering (1)
reverse engineering board (11)
help: Reverse engineering a DLL file (10)
PCB reverse-engineering professionals required! (5)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS