You will need a pair of lines in the startup Movlw 07h ; Val for all digital Movwf CMCON ; for the CMCON reg Rgds Steve -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf Of Jan van Dijk Sent: 05 April 2007 14:36 To: Microcontroller discussion list - Public. Subject: Re: [PIC] Converting 16F84 DCC decoder to 16F628 (or 16F648) Okay, I'm altering the original file so it will work again with the 16C84, but with using the microchip include file... I found a rather strange thing, all registers maps to the register which are defined in the P16C84.INC, only 2 do not: assembly file DECODER.ASM: eecon1 equ 08 rd equ 0 wr equ 1 wren equ 2 eecon2 equ 09 include file P16C84: EECON1 EQU H'0088' EECON2 EQU H'0089' These addresses are actually used, which rather surpises me, since they don't match with the include file: ;Generic EE write subroutine that writes eedata into eeadr. If the processor ;is busy with a previous write operation, the subroutine returns without ;writing. Inputs are eeadr and eeread. EEwrite movlw 0x55 movwf eecon2 movlw 0xAA movwf eecon2 bsf eecon1,wr eewrcon btfsc eecon1,wr goto eewrcon bcf eecon1,wren bcf status,rp0 return Is there anyone who might have a clue what's going on? Best regards, Jan 2007/4/5, Jan van Dijk : > > Hello, > > Thanks for the given input! I made a MPLAB project and added the assembler > file to it. The code compiles when renaming the config to con_fig, but no > include files are used... > > The control registers are defined in the program start: > > *;Variable definition - PIC16C84 control registers.* > > *f0 equ 00 > rtcc equ 01 > pc equ 02 > status equ 03 > carry equ 0 > zbit equ 2 > rp0 equ 5 > rp1 equ 6 > fsr equ 04 > porta equ 05 > portb equ 06 > eedata equ 08 > eeadr equ 09 > eecon1 equ 08 > rd equ 0 > wr equ 1 > wren equ 2 > eecon2 equ 09 > pclath equ 0A > intcon equ 0B > f equ 1 > w equ * 0 > > And they are used in the program... also some 'magical' numbers are used > within the code to set the registers: > > *;Init sets porta as all outputs, pin b0 as input and the rest of portb as > ;outputs and sets the rtcc counter to divide by 32 (16us at 8MHz clock). > ;FSR is set to 88h for indirect access to INTCON register from page 00. * > > *Init movlw b'00000001' ;RA0=input, RA1,2=outputs > tris porta > clrf porta > movlw 0x00 ;All of PortB = outputs > tris portb > clrf portb > clrf intcon > movlw 0x84 > option > movlw 0x88 > movwf fsr* > > Luckily the code is well documented... but I might have to do some > puzzling then :) > > Best regards, > > Jan > > > > 2007/4/2, Herbert Graf : > > > > On Mon, 2007-04-02 at 21:11 +0100, Steve Smith wrote: > > > Well if you replace all the labels 'config' with con_fig it compiles > > for a > > > 628 in mp lab but I haven't looked at the functional differences > > between the > > > parts shouldn't be too bad > > > > Hello Steve, > > > > There are a few issues you must look in to. > > > > First off, yes, you have to "translate" the config settings to the 628. > > Generally the 628 has "more" stuff in the config section, so you must > > turn off the things that the 16F84 doesn't have that may interfere with > > operation. > > > > Second, the analog comparators in the 628 have to be turned off, by > > default they are on. > > > > Third, and this is the one that either is zero work or TONS of work: you > > have to look at how the assembly is written. If the writers used the > > MChip include files, and did proper work with the bank settings ( i.e. > > using BANKSEL) you should be OK. However, if they defined their own > > symbols for FSRs, or, even worse, used the numeric values you have ALOT > > of work ahead of you. > > > > Same with general RAM, if they did things proper you should be fine, if > > they used "defines" with absolute numbers then you may have alot of work > > ahead of you. > > > > Good luck! > > > > TTYL > > > > -- > > http://www.piclist.com PIC/SX FAQ & list archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist