Page 1 of 1

Upgrade from Version 2 PIC development boards

Posted: Wed Jan 19, 2011 1:03 pm
by CornwallCollege
In the past we have been using Version 2 PIC development boards with TASM & PPP2.5.
We have now purchased some Eblock boards - HP488 which uses PPP3. When trying to load old OBJ files into PPP3 we get an “Bad HEX FILE (no EOF marker found)” error message.
Is it possible to use old TASM & OBJ files generated with PPP3 or will we have to move on to use MPASM and rewrite all the codes?

Re: Upgrade from Version 2 PIC development boards

Posted: Wed Jan 19, 2011 1:41 pm
by Steve
Unfortunately, we stopped making the V2 board almost a decade ago and stopped using TASM around then too.

I think your best option is to re-write the TASM code as MPASM code. This should not be too difficult (from my memory) as the opcodes are very similar - perhaps a quick search and replace will solve the majority of your problems.

Re: Upgrade from Version 2 PIC development boards

Posted: Wed Jan 19, 2011 10:49 pm
by medelec35
Steve wrote:I think your best option is to re-write the TASM code as MPASM code.
I have found some free software which I tried on windows 7. It converts TASM to MPASM ,so no editing to do.
It's called Asmtidy and you can download from.
http://www.unusualelectronics.co.uk/pro ... smtidy.php
As an example I loaded:

Code: Select all

#DEFINE PAGE0   BCF $03,5
#DEFINE PAGE1   BSF $03,5

	List P = PIC16F877, R=DEC; 
        __CONFIG   h'3F31'

INDF:    .EQU $00  ;page 0, 1, 2, 3
OPTION:  .EQU $01  ;page 1, 3
PCL:     .EQU $02  ;page 0, 1, 2, 3
STATUS:  .EQU $03  ;page 0, 1, 2, 3
FSR:     .EQU $04  ;page 0, 1, 2, 3

PORTA:   .EQU $05  ;page 0
TRISA:   .EQU $05  ;page 1
PORTB:   .EQU $06  ;page 0, 2
TRISB:   .EQU $06  ;page 1, 3
PORTC:   .EQU $07  ;page 0
TRISC:   .EQU $07  ;page 1
PORTD:   .EQU $08  ;page 0
TRISD:   .EQU $08  ;page 1
PORTE:   .EQU $09  ;page 0
TRISE:   .EQU $09  ;page 1

PCLATH:  .EQU $0A  ;page 0, 1, 2, 3
INTCON:  .EQU $0B  ;page 0, 1, 2, 3

EEDATA:  .EQU $0C  ;page 2
EECON1:  .EQU $0C  ;page 3
         
PIR2:    .EQU $0D  ;page 0
EEADR:   .EQU $0D  ;page 2
EECON2:  .EQU $0D  ;page 3

ADCON1:  .EQU $1F  ;page 1

SLOWIT:   .EQU $20        ; pause counter
CLKCNT:   .EQU $21
CLKSEC:   .EQU $22
CLKMIN:   .EQU $23
CLKHRS:   .EQU $24
LOOP:     .EQU $25
LOOPA:    .EQU $26 
RSLINE:   .EQU $27
STORE:    .EQU $28 
STORE1:   .EQU $29 
STORE2:   .EQU $2A
STORE3:   .EQU $2B
ZONESVAL: .EQU $2C     ; current val of zones status
ALARMSTATUS: .EQU $2D  ; controls the following:
                       ; bit 0 buzzer
                       ; bit 1 strobe
                       ; bit 2 bell
                       ; bit 3 -
                       ; bit 4 Panic flag
                       ; bit 5 passive entry zone (just turns on buzzer when entered)
                       ; bit 6 power interrupt flag
                       ; bit 7 alarm on flag

SWITCH1:   .EQU $2E   ; multiplex val for rows
SWVAL:     .EQU $2F   ; input val from RB0-RB3
COL:       .EQU $30   ; column counter (inc in decimal)
ROW:       .EQU $31   ; row counter (inc as matrix val)
ROWNUM:    .EQU $32   ; row counter (inc in decimal)
ALARMZONE: .EQU $33   ; holds status of which zone triggered
KEYPRESS:  .EQU $34   ; value of key pressed keypad1
PIN0:      .EQU $35   ; 1st pin number val FIRST KEYPAD
PIN1:      .EQU $36   ; 2nd pin number val
PIN2:      .EQU $37   ; 3rd pin number val
PIN3:      .EQU $38   ; 4th pin number val

EXITTIME:  .EQU $39   ; entry/exit delay
EXITZONE:  .EQU $3A   ; entry/exit zone
INCLZONE:  .EQU $3B   ; zones to be included in monitoring

BELLTIME      .EQU $3C   ; bell on time value in BCD mins
FLASH:        .EQU $3D   ; flag for flashing buzzer LED when zone incorrectly open during alarm setting
ZONENORMAL:   .EQU $3E  ; normal zone logic
ENGINEERSET:  .EQU $3F ; flag to indicate if ENGINEER has been called
PREVALARMZONE .EQU $40 ; previous alarm condition register
ENTRYDELAY:   .EQU $41 ; counter for entry/exit delay
PIN4:         .EQU $42   ; 1st pin number val FOR 2ND KEYPAD
PIN5:         .EQU $43   ; 2nd pin number val
PIN6:         .EQU $44   ; 3rd pin number val
PIN7:         .EQU $45   ; 4th pin number val
KEYPRESS2:    .EQU $46   ; value of key pressed keypad2
ENTRYTIME2:   .EQU $47   ; entry time for keypad2
ENTRYDELAY2:  .EQU $48   ; counter for keypad2 entry delay
CLKCNT2:      .EQU $49
STORED        .EQU $4A   ; temp store for keypad2

COUNT0  .EQU    0x50            ;lsb
COUNT1  .EQU    0x51
COUNT2  .EQU    0x52            ;msb
DIGIT1  .EQU    0x53            ;lsd
DIGIT2  .EQU    0x54
BITCNT  .EQU    0x5B
DIGCNT  .EQU    0x5C
STOREX: .EQU $60
STOREY: .EQU $61

          ; locations up to $7F are available

             ;************************************************************
             ;           Bit Definitions
             ;************************************************************

W:      .EQU 0
F:      .EQU 1
C:      .EQU 0
DC:     .EQU 1 
Z:      .EQU 2

RP0:    .EQU 5           ;STATUS reg
RP1:    .EQU 6           ;STATUS reg
GIE:    .EQU 7           ;INTCON reg

RD:     .EQU 0  ;EECON1 reg eeprom read enable flag
WR:     .EQU 1  ;EECON1 reg eeprom write initiate flag
WREN:   .EQU 2  ;EECON1 reg eeprom write enable flag

EEPGD:  .EQU 7           ;EECON1 reg 
EEIF:   .EQU 4           ;PIR2 reg 

BUZZER: .EQU 0
STROBE: .EQU 1
BELL:   .EQU 2
PANIC:  .EQU 4
RBIF:   .EQU 0

;............. DATA EEPROM USE

                ; 0-3  PIN CODE
                ; 4    ZONES EXCLUDED
                ; 5    ENTRY/EXIT ZONE
                ; 6    ENTRY/EXIT DELAY
                ; 7    ZONES INTRUDED (AlarmZone)
                ; 8    ALARM ON/OFF & BELL, BUZZER, STROBE STATUS (AlarmStatus)
                ; 9    BELL ON TIME (MAX 15 MINS)
                ; 10   NORMAL ZONE STATUS
                ; 11-14 2ND PIN CODE
                ; 15   ENTRY DELAY VIA KEYPAD2

        .ORG $0004      ;Interrupt vector address
        GOTO GIEOFF     ;Jump to interrupt routine on interrupt
        .ORG $0005      ;Start of program memory

GIEOFF: BCF INTCON,GIE  ;turn off global interrupts
        BTFSC INTCON,GIE
        goto GIEOFF
        goto START

TABLCD: addwf PCL,F     ;LCD initialisation table
        retlw %00110011 ;initialise lcd - first byte
        retlw %00110011 ;2nd byte (repeat of first)
        retlw %00110010 ;set for 4-bit operation
        retlw %00101100 ;set for 2 lines
        retlw %00000110 ;set entry mode to increment each address
        retlw %00001100 ;set display on, cursor off, blink off
        retlw %00000001 ;clear display
        retlw %00000010 ;return home, cursor & RAM to zero
                        ;end inititalisation table

ALLOFF: addwf PCL,F
        retlw 'A'
        retlw 'L'
        retlw 'L'
        retlw ' '
        retlw 'O'
        retlw 'F'
        retlw 'F'
        retlw ' '

MESSAGON: addwf PCL,F
        retlw 'A'
        retlw 'L'
        retlw 'A'
        retlw 'R'
        retlw 'M'
        retlw ' '
        retlw 'O'
        retlw 'N'
        retlw ' '

MESSAG2: addwf PCL,F
        retlw ' '
        retlw ' '
        retlw 'E'
        retlw 'N'
        retlw 'T'
        retlw 'R'
        retlw 'Y'
        retlw ' '

CHKVAL: addwf PCL,F
        retlw %01011001 ;59 secs max
        retlw %01011001 ;59 mins max
        retlw %00100011 ;23 hours max

VALUE:  ADDWF PCL,F       ;lookup table for key allocation
        retlw '1'
        retlw '2'
        retlw '3'
        retlw 'A'
        retlw '4'
        retlw '5'
        retlw '6'
        retlw 'B'
        retlw '7'
        retlw '8'
        retlw '9'
        retlw 'C'
        retlw '-'
        retlw '0'
        retlw 'E'
        retlw 'D'

BITVALUE: ADDWF PCL,F       ;lookup table for decimal to bit conversion
        retlw 0
        retlw 1
        retlw 2
        retlw 4
        retlw 8
        retlw 16
        retlw 32
        retlw 64
        retlw 128

PINCODE: ADDWF PCL,F       ; change pin code message
        retlw 'C'
        retlw 'H'
        retlw 'A'
        retlw 'N'
        retlw 'G'
        retlw 'E'
        retlw ' '
        retlw 'P'
        retlw 'I'
        retlw 'N'
        retlw ' '
        retlw 'C'
        retlw 'O'
        retlw 'D'
        retlw 'E'
        retlw ' '

PIN2MSG: ADDWF PCL,F       ; change 2ND pin code message
        retlw 'S'
        retlw 'E'
        retlw 'T'
        retlw ' '
        retlw '2'
        retlw 'N'
        retlw 'D'
        retlw ' '
        retlw 'P'
        retlw 'I'
        retlw 'N'
        retlw ' '
        retlw 'C'
        retlw 'O'
        retlw 'D'
        retlw 'E'

ENTRYTIME: ADDWF PCL,F       ; change ENTRY/EXIT time message
        retlw 'S'
        retlw 'E'
        retlw 'T'
        retlw ' '
        retlw 'I'
        retlw 'N'
        retlw '/'
        retlw 'O'
        retlw 'U'
        retlw 'T'
        retlw ' '
        retlw 'T'
        retlw 'I'
        retlw 'M'
        retlw 'E'
        retlw ' '

BELLTIMEMSG: ADDWF PCL,F       ; change ENTRY/EXIT time message
        retlw 'S'
        retlw 'E'
        retlw 'T'
        retlw ' '
        retlw 'B'
        retlw 'E'
        retlw 'L'
        retlw 'L'
        retlw ' '
        retlw 'O'
        retlw 'N'
        retlw ' '
        retlw 'T'
        retlw 'I'
        retlw 'M'
        retlw 'E'

ENTRYZONE: ADDWF PCL,F       ; set ENTRY/EXIT zone message
        retlw 'S'
        retlw 'E'
        retlw 'T'
        retlw ' '
        retlw 'I'
        retlw 'N'
        retlw '/'
        retlw 'O'
        retlw 'U'
        retlw 'T'
        retlw ' '
        retlw 'Z'
        retlw 'O'
        retlw 'N'
        retlw 'E'
        retlw ' '

MODEMSG: ADDWF PCL,F       ; mode message
        retlw 'S'
        retlw 'E'
        retlw 'L'
        retlw 'E'
        retlw 'C'
        retlw 'T'
        retlw ' '
        retlw 'M'
        retlw 'O'
        retlw 'D'
        retlw 'E'
        retlw ' '
        retlw ' '
        retlw ' '
        retlw ' '
        retlw ' '

WATCHMSG: ADDWF PCL,F       ; zones to be watched message
        retlw 'S'
        retlw 'E'
        retlw 'T'
        retlw ' '
        retlw 'W'
        retlw 'A'
        retlw 'T'
        retlw 'C'
        retlw 'H'
        retlw ' '
        retlw 'Z'
        retlw 'O'
        retlw 'N'
        retlw 'E'
        retlw 'S'
        retlw ' '

OPENZONE: ADDWF PCL,F       ; zones incorrectly open when alarm is being set
        retlw 'C'
        retlw 'H'
        retlw 'E'
        retlw 'C'
        retlw 'K'
        retlw ' '
        retlw 'O'
        retlw 'P'
        retlw 'E'
        retlw 'N'
        retlw ' '
        retlw 'Z'
        retlw 'O'
        retlw 'N'
        retlw 'E'
        retlw 'S'

ZONELOGIC: ADDWF PCL,F       ; assess zone logic message (i.e normally open or normally closed)
        retlw 'A'
        retlw 'U'
        retlw 'T'
        retlw 'O'
        retlw ' '
        retlw 'Z'
        retlw 'O'
        retlw 'N'
        retlw 'E'
        retlw ' '
        retlw 'A'
        retlw 'S'
        retlw 'S'
        retlw 'E'
        retlw 'S'
        retlw 'S'

SHOWLOGIC: ADDWF PCL,F       ; assess zone logic message (i.e normally open or normally closed)
        retlw 'N'
        retlw 'O'
        retlw 'R'
        retlw 'M'
        retlw ' '
        retlw 'Z'
        retlw 'O'
        retlw 'N'
        retlw 'E'
        retlw ' '
        retlw 'L'
        retlw 'O'
        retlw 'G'
        retlw 'I'
        retlw 'C'
        retlw ' '

PASSIVEMSG: ADDWF PCL,F       ; passive alarm message
        retlw 'M'
        retlw 'O'
        retlw 'N'
        retlw 'I'
        retlw 'T'
        retlw 'O'
        retlw 'R'
        retlw ' '

START:  bcf STATUS,RP0
        bcf STATUS,RP1
        clrf PORTA
        clrf PORTB
        clrf PORTC
        clrf PORTD
        clrf PORTE
        PAGE1
        movlw %11011111     ;RB0-RB4, RB6-RB7 as input, RB5 as output
        movwf TRISB
        movlw %00001111     ;RC0-RC3 as input, RC4-RC7 as output
        movwf TRISC         
        movlw 255
        movwf TRISD         ;PORTD as input
        clrf TRISE          ;PORTE as output
        movlw %00000111     ;PORT A/E as digital
        movwf ADCON1        ;
        movlw %11000000     ;RA0-RA5 as outputs
        movwf TRISA

        movlw %00000110     ;timer 1:128 (1/25th sec)
        movwf OPTION
        PAGE0
        clrf INTCON
        call PAUSIT     ;1/5 sec delay

LCDSET: clrf LOOP       ;clr LCD set-up loop
        clrf RSLINE     ;clear RS line for instruction send
LCDST2: movf LOOP,W     ;get table address
        call TABLCD     ;get set-up instruction
        call LCDOUT     ;perform it
        incf LOOP,F     ;inc loop
        btfss LOOP,3    ;has last LCD set-up instruction now been done?
        goto LCDST2     ;no
        call PAUSIT     ;1/5 sec delay

        clrf ENGINEERSET
        bsf ALARMSTATUS,6   ; set Power interruption flag

        call KEYPAD1    ; is ENGINEER code to be entered following power-up
        movf KEYPRESS,W ; with key 'D' pressed?
        xorlw 'D'
        btfss STATUS,Z
        goto SETCLK     ; no

        clrf ALARMZONE
        clrf ALARMSTATUS
        bsf ENGINEERSET,0
        bcf ALARMSTATUS,6   ; clear Power interruption flag

        movlw %10000001 ; default set INCLZONE for zones 1 & 8
        movwf STORE1
        movlw 4
        call SETPRM

        movlw %00000001 ; default set entry/exit zone
        movwf STORE1
        movlw 5
        call SETPRM

        movlw 30        ; default set EXITTIME to 30 secs in binary
        movwf STORE1
        movlw 6
        call SETPRM

        clrf STORE1     ; default clear INTRUDED status
        movlw 7
        call SETPRM
        clrf PORTE

        clrf STORE1     ; default clear ALARMSTATUS (bell etc)
        bcf STORE1,BELL
        movlw 8
        call SETPRM

        movlw %00010101 ; default set bell switch-off time to 15 mins in BCD
        movwf STORE1
        movlw 9
        call SETPRM

        movlw %00000000 ; default set for "normal" zone status - all open
        movwf STORE1
        movlw 10
        call SETPRM

        movlw 30        ; default set ENTRYTIME to 30 secs in binary for keypad2
        movwf STORE1
        movlw 15
        call SETPRM

        call ENGINEER   ; yes, set ENGINEER entry code and reset all defaults

SETCLK: clrf CLKSEC     ;clear seconds counter
        clrf CLKMIN     ;clear minutes counter
        clrf CLKHRS     ;clear hours counter
        clrf PREVALARMZONE
        clrf ENTRYDELAY
        clrf ENTRYDELAY2

        movlw 25        ;initial basic CLKCNT val for secs timing
        movwf CLKCNT

        movlw 0         ; RECALL PIN CODE
        call PRMGET
        movwf PIN0
        movlw 1
        call PRMGET
        movwf PIN1
        movlw 2
        call PRMGET
        movwf PIN2
        movlw 3
        call PRMGET
        movwf PIN3

        movlw 4            ; RECALL INCLUDED/EXCLUDED ZONES
        call PRMGET
        movwf INCLZONE
        bsf INCLZONE,7     ; ensure bit 7 (1st PANIC zone) is always on

        movlw 5            ; RECALL ENTRY/EXIT ZONE
        call PRMGET
        movwf EXITZONE
        movlw 6            ; RECALL ENTRY/EXIT TIME
        call PRMGET
        movwf EXITTIME
        movlw 7            ; RECALL ALARMZONE STATUS
        call PRMGET
        movwf ALARMZONE
        movlw 8            ; RECALL ALARMSTATUS STATUS
        call PRMGET
        movwf ALARMSTATUS  ; and activate buzzer/strobe if needed (but not bell)
        andlw %00000011
        movwf PORTE
        movlw 9            ; RECALL BELL ON TIME
        call PRMGET
        movwf BELLTIME
        movlw 10           ; RECALL "NORMAL ZONE STATUS
        call PRMGET
        movwf ZONENORMAL

        movlw 11           ; RECALL PIN CODE 2
        call PRMGET
        movwf PIN4
        movlw 12
        call PRMGET
        movwf PIN5
        movlw 13
        call PRMGET
        movwf PIN6
        movlw 14
        call PRMGET
        movwf PIN7

        movlw 15           ; RECALL ENTRY TIME FOR KEYPAD2
        call PRMGET
        movwf ENTRYTIME2

        btfss ALARMSTATUS,7 ; is alarm on?
        goto ITSOFF
        call CHECKZONE2
        bsf ALARMSTATUS,6   ; set Power interruption flag
        goto MAIN

ITSOFF: call ALARMOFF   ; show ALARM OFF message
        btfsc ENGINEERSET,0 ; has ENGINEER been called?
        goto MAIN       ;yes

        call LCD21      ;set address for line 1 cell 1
        bsf RSLINE,4    ;set RS for data send
After conversion got:

Code: Select all

#define		page0	BCF $03,5
#define		page1	BSF $03,5

	LIST	P = PIC16F877,R=DEC
	__CONFIG	h'3F31'

indf		EQU	H'00'		;Page 0, 1, 2, 3
option		EQU	H'01'		;Page 1, 3
pcl		EQU	H'02'		;Page 0, 1, 2, 3
status		EQU	H'03'		;Page 0, 1, 2, 3
fsr		EQU	H'04'		;Page 0, 1, 2, 3

porta		EQU	H'05'		;Page 0
trisa		EQU	H'05'		;Page 1
portb		EQU	H'06'		;Page 0, 2
trisb		EQU	H'06'		;Page 1, 3
portc		EQU	H'07'		;Page 0
trisc		EQU	H'07'		;Page 1
portd		EQU	H'08'		;Page 0
trisd		EQU	H'08'		;Page 1
porte		EQU	H'09'		;Page 0
trise		EQU	H'09'		;Page 1

pclath		EQU	H'0A'		;Page 0, 1, 2, 3
intcon		EQU	H'0B'		;Page 0, 1, 2, 3

eedata		EQU	H'0C'		;Page 2
eecon1		EQU	H'0C'		;Page 3

pir2		EQU	H'0D'		;Page 0
eeadr		EQU	H'0D'		;Page 2
eecon2		EQU	H'0D'		;Page 3

adcon1		EQU	H'1F'		;Page 1

slowit		EQU	H'20'		;Pause counter
clkcnt		EQU	H'21'
clksec		EQU	H'22'
clkmin		EQU	H'23'
clkhrs		EQU	H'24'
loop		EQU	H'25'
loopa		EQU	H'26'
rsline		EQU	H'27'
store		EQU	H'28'
store1		EQU	H'29'
store2		EQU	H'2A'
store3		EQU	H'2B'
zonesval	EQU	H'2C'		;Current val of zones status
alarmstatus	EQU	H'2D'		;Controls the following:
					;Bit 0 buzzer
					;Bit 1 strobe
					;Bit 2 bell
					;Bit 3 -
					;Bit 4 panic flag
					;Bit 5 passive entry zone (just turns on buzzer when entered)
					;Bit 6 power interrupt flag
					;Bit 7 alarm on flag

switch1		EQU	H'2E'		;Multiplex val for rows
swval		EQU	H'2F'		;Input val from rb0-rb3
col		EQU	H'30'		;Column counter (inc in decimal)
row		EQU	H'31'		;Row counter (inc as matrix val)
rownum		EQU	H'32'		;Row counter (inc in decimal)
alarmzone	EQU	H'33'		;Holds status of which zone triggered
keypress	EQU	H'34'		;Value of key pressed keypad1
pin0		EQU	H'35'		;1st pin number val first keypad
pin1		EQU	H'36'		;2nd pin number val
pin2		EQU	H'37'		;3rd pin number val
pin3		EQU	H'38'		;4th pin number val

exittime	EQU	H'39'		;Entry/exit delay
exitzone	EQU	H'3A'		;Entry/exit zone
inclzone	EQU	H'3B'		;Zones to be included in monitoring

belltime	EQU	H'3C'		;Bell on time value in bcd mins
flash		EQU	H'3D'		;Flag for flashing buzzer led when zone incorrectly open during alarm setting
zonenormal	EQU	H'3E'		;Normal zone logic
engineerset	EQU	H'3F'		;Flag to indicate if engineer has been called
prevalarmzone	EQU	H'40'		;Previous alarm condition register
entrydelay	EQU	H'41'		;Counter for entry/exit delay
pin4		EQU	H'42'		;1st pin number val for 2nd keypad
pin5		EQU	H'43'		;2nd pin number val
pin6		EQU	H'44'		;3rd pin number val
pin7		EQU	H'45'		;4th pin number val
keypress2	EQU	H'46'		;Value of key pressed keypad2
entrytime2	EQU	H'47'		;Entry time for keypad2
entrydelay2	EQU	H'48'		;Counter for keypad2 entry delay
clkcnt2		EQU	H'49'
stored		EQU	H'4A'		;Temp store for keypad2

count0		EQU	0x50		;Lsb
count1		EQU	0x51
count2		EQU	0x52		;Msb
digit1		EQU	0x53		;Lsd
digit2		EQU	0x54
bitcnt		EQU	0x5B
digcnt		EQU	0x5C
storex		EQU	H'60'
storey		EQU	H'61'

					;Locations up to $7f are available

					;************************************************************
					;Bit definitions
					;************************************************************

w		EQU	0
f		EQU	1
c		EQU	0
dc		EQU	1
z		EQU	2

rp0		EQU	5		;Status reg
rp1		EQU	6		;Status reg
gie		EQU	7		;Intcon reg

rd		EQU	0		;Eecon1 reg eeprom read enable flag
wr		EQU	1		;Eecon1 reg eeprom write initiate flag
wren		EQU	2		;Eecon1 reg eeprom write enable flag

eepgd		EQU	7		;Eecon1 reg
eeif		EQU	4		;Pir2 reg

buzzer		EQU	0
strobe		EQU	1
bell		EQU	2
panic		EQU	4
rbif		EQU	0

;............. DATA EEPROM USE

					;0-3  pin code
					;4    zones excluded
					;5    entry/exit zone
					;6    entry/exit delay
					;7    zones intruded (alarmzone)
					;8    alarm on/off & bell, buzzer, strobe status (alarmstatus)
					;9    bell on time (max 15 mins)
					;10   normal zone status
					;11-14 2nd pin code
					;15   entry delay via keypad2

	ORG	H'0004'			;Interrupt vector address
	GOTO	gieoff			;Jump to interrupt routine on interrupt
	ORG	H'0005'			;Start of program memory

gieoff	
	BCF	intcon,gie		;Turn off global interrupts
	BTFSC	intcon,gie
	GOTO	gieoff
	GOTO	start

tablcd	
	ADDWF	pcl,f			;Lcd initialisation table
	RETLW	B'00110011'		;Initialise lcd - first byte
	RETLW	B'00110011'		;2nd byte (repeat of first)
	RETLW	B'00110010'		;Set for 4-bit operation
	RETLW	B'00101100'		;Set for 2 lines
	RETLW	B'00000110'		;Set entry mode to increment each address
	RETLW	B'00001100'		;Set display on, cursor off, blink off
	RETLW	B'00000001'		;Clear display
	RETLW	B'00000010'		;Return home, cursor & ram to zero
					;End inititalisation table

alloff	
	ADDWF	pcl,f
	RETLW	'A'
	RETLW	'L'
	RETLW	'L'
	RETLW	' '
	RETLW	'O'
	RETLW	'F'
	RETLW	'F'
	RETLW	' '

messagon
	ADDWF	pcl,f
	RETLW	'A'
	RETLW	'L'
	RETLW	'A'
	RETLW	'R'
	RETLW	'M'
	RETLW	' '
	RETLW	'O'
	RETLW	'N'
	RETLW	' '

messag2	
	ADDWF	pcl,f
	RETLW	' '
	RETLW	' '
	RETLW	'E'
	RETLW	'N'
	RETLW	'T'
	RETLW	'R'
	RETLW	'Y'
	RETLW	' '

chkval	
	ADDWF	pcl,f
	RETLW	B'01011001'		;59 secs max
	RETLW	B'01011001'		;59 mins max
	RETLW	B'00100011'		;23 hours max

value	
	ADDWF	pcl,f			;Lookup table for key allocation
	RETLW	'1'
	RETLW	'2'
	RETLW	'3'
	RETLW	'A'
	RETLW	'4'
	RETLW	'5'
	RETLW	'6'
	RETLW	'B'
	RETLW	'7'
	RETLW	'8'
	RETLW	'9'
	RETLW	'C'
	RETLW	'-'
	RETLW	'0'
	RETLW	'E'
	RETLW	'D'

bitvalue
	ADDWF	pcl,f			;Lookup table for decimal to bit conversion
	RETLW	0
	RETLW	1
	RETLW	2
	RETLW	4
	RETLW	8
	RETLW	D'16'
	RETLW	D'32'
	RETLW	D'64'
	RETLW	D'128'

pincode	
	ADDWF	pcl,f			;Change pin code message
	RETLW	'C'
	RETLW	'H'
	RETLW	'A'
	RETLW	'N'
	RETLW	'G'
	RETLW	'E'
	RETLW	' '
	RETLW	'P'
	RETLW	'I'
	RETLW	'N'
	RETLW	' '
	RETLW	'C'
	RETLW	'O'
	RETLW	'D'
	RETLW	'E'
	RETLW	' '

pin2msg	
	ADDWF	pcl,f			;Change 2nd pin code message
	RETLW	'S'
	RETLW	'E'
	RETLW	'T'
	RETLW	' '
	RETLW	'2'
	RETLW	'N'
	RETLW	'D'
	RETLW	' '
	RETLW	'P'
	RETLW	'I'
	RETLW	'N'
	RETLW	' '
	RETLW	'C'
	RETLW	'O'
	RETLW	'D'
	RETLW	'E'

entrytime
	ADDWF	pcl,f			;Change entry/exit time message
	RETLW	'S'
	RETLW	'E'
	RETLW	'T'
	RETLW	' '
	RETLW	'I'
	RETLW	'N'
	RETLW	'/'
	RETLW	'O'
	RETLW	'U'
	RETLW	'T'
	RETLW	' '
	RETLW	'T'
	RETLW	'I'
	RETLW	'M'
	RETLW	'E'
	RETLW	' '

belltimemsg
	ADDWF	pcl,f			;Change entry/exit time message
	RETLW	'S'
	RETLW	'E'
	RETLW	'T'
	RETLW	' '
	RETLW	'B'
	RETLW	'E'
	RETLW	'L'
	RETLW	'L'
	RETLW	' '
	RETLW	'O'
	RETLW	'N'
	RETLW	' '
	RETLW	'T'
	RETLW	'I'
	RETLW	'M'
	RETLW	'E'

entryzone
	ADDWF	pcl,f			;Set entry/exit zone message
	RETLW	'S'
	RETLW	'E'
	RETLW	'T'
	RETLW	' '
	RETLW	'I'
	RETLW	'N'
	RETLW	'/'
	RETLW	'O'
	RETLW	'U'
	RETLW	'T'
	RETLW	' '
	RETLW	'Z'
	RETLW	'O'
	RETLW	'N'
	RETLW	'E'
	RETLW	' '

modemsg	
	ADDWF	pcl,f			;Mode message
	RETLW	'S'
	RETLW	'E'
	RETLW	'L'
	RETLW	'E'
	RETLW	'C'
	RETLW	'T'
	RETLW	' '
	RETLW	'M'
	RETLW	'O'
	RETLW	'D'
	RETLW	'E'
	RETLW	' '
	RETLW	' '
	RETLW	' '
	RETLW	' '
	RETLW	' '

watchmsg
	ADDWF	pcl,f			;Zones to be watched message
	RETLW	'S'
	RETLW	'E'
	RETLW	'T'
	RETLW	' '
	RETLW	'W'
	RETLW	'A'
	RETLW	'T'
	RETLW	'C'
	RETLW	'H'
	RETLW	' '
	RETLW	'Z'
	RETLW	'O'
	RETLW	'N'
	RETLW	'E'
	RETLW	'S'
	RETLW	' '

openzone
	ADDWF	pcl,f			;Zones incorrectly open when alarm is being set
	RETLW	'C'
	RETLW	'H'
	RETLW	'E'
	RETLW	'C'
	RETLW	'K'
	RETLW	' '
	RETLW	'O'
	RETLW	'P'
	RETLW	'E'
	RETLW	'N'
	RETLW	' '
	RETLW	'Z'
	RETLW	'O'
	RETLW	'N'
	RETLW	'E'
	RETLW	'S'

zonelogic
	ADDWF	pcl,f			;Assess zone logic message (i.e normally open or normally closed)
	RETLW	'A'
	RETLW	'U'
	RETLW	'T'
	RETLW	'O'
	RETLW	' '
	RETLW	'Z'
	RETLW	'O'
	RETLW	'N'
	RETLW	'E'
	RETLW	' '
	RETLW	'A'
	RETLW	'S'
	RETLW	'S'
	RETLW	'E'
	RETLW	'S'
	RETLW	'S'

showlogic
	ADDWF	pcl,f			;Assess zone logic message (i.e normally open or normally closed)
	RETLW	'N'
	RETLW	'O'
	RETLW	'R'
	RETLW	'M'
	RETLW	' '
	RETLW	'Z'
	RETLW	'O'
	RETLW	'N'
	RETLW	'E'
	RETLW	' '
	RETLW	'L'
	RETLW	'O'
	RETLW	'G'
	RETLW	'I'
	RETLW	'C'
	RETLW	' '

passivemsg
	ADDWF	pcl,f			;Passive alarm message
	RETLW	'M'
	RETLW	'O'
	RETLW	'N'
	RETLW	'I'
	RETLW	'T'
	RETLW	'O'
	RETLW	'R'
	RETLW	' '

start	
	BCF	status,rp0
	BCF	status,rp1
	CLRF	porta
	CLRF	portb
	CLRF	portc
	CLRF	portd
	CLRF	porte
	PAGE1
	MOVLW	B'11011111'		;Rb0-rb4, rb6-rb7 as input, rb5 as output
	MOVWF	trisb
	MOVLW	B'00001111'		;Rc0-rc3 as input, rc4-rc7 as output
	MOVWF	trisc
	MOVLW	D'255'
	MOVWF	trisd			;Portd as input
	CLRF	trise			;Porte as output
	MOVLW	B'00000111'		;Port a/e as digital
	MOVWF	adcon1
	MOVLW	B'11000000'		;Ra0-ra5 as outputs
	MOVWF	trisa

	MOVLW	B'00000110'		;Timer 1:128 (1/25th sec)
	MOVWF	option
	PAGE0
	CLRF	intcon
	CALL	pausit			;1/5 sec delay

lcdset	
	CLRF	loop			;Clr lcd set-up loop
	CLRF	rsline			;Clear rs line for instruction send
lcdst2	
	MOVF	loop,w			;Get table address
	CALL	tablcd			;Get set-up instruction
	CALL	lcdout			;Perform it
	INCF	loop,f			;Inc loop
	BTFSS	loop,3			;Has last lcd set-up instruction now been done?
	GOTO	lcdst2			;No
	CALL	pausit			;1/5 sec delay

	CLRF	engineerset
	BSF	alarmstatus,6		;Set power interruption flag

	CALL	keypad1			;Is engineer code to be entered following power-up
	MOVF	keypress,w		;With key 'd' pressed?
	XORLW	'D'
	BTFSS	status,z
	GOTO	setclk			;No

	CLRF	alarmzone
	CLRF	alarmstatus
	BSF	engineerset,0
	BCF	alarmstatus,6		;Clear power interruption flag

	MOVLW	B'10000001'		;Default set inclzone for zones 1 & 8
	MOVWF	store1
	MOVLW	4
	CALL	setprm

	MOVLW	B'00000001'		;Default set entry/exit zone
	MOVWF	store1
	MOVLW	5
	CALL	setprm

	MOVLW	D'30'			;Default set exittime to 30 secs in binary
	MOVWF	store1
	MOVLW	6
	CALL	setprm

	CLRF	store1			;Default clear intruded status
	MOVLW	7
	CALL	setprm
	CLRF	porte

	CLRF	store1			;Default clear alarmstatus (bell etc)
	BCF	store1,bell
	MOVLW	8
	CALL	setprm

	MOVLW	B'00010101'		;Default set bell switch-off time to 15 mins in bcd
	MOVWF	store1
	MOVLW	9
	CALL	setprm

	MOVLW	B'00000000'		;Default set for "normal" zone status - all open
	MOVWF	store1
	MOVLW	D'10'
	CALL	setprm

	MOVLW	D'30'			;Default set entrytime to 30 secs in binary for keypad2
	MOVWF	store1
	MOVLW	D'15'
	CALL	setprm

	CALL	engineer		;Yes, set engineer entry code and reset all defaults

setclk	
	CLRF	clksec			;Clear seconds counter
	CLRF	clkmin			;Clear minutes counter
	CLRF	clkhrs			;Clear hours counter
	CLRF	prevalarmzone
	CLRF	entrydelay
	CLRF	entrydelay2

	MOVLW	D'25'			;Initial basic clkcnt val for secs timing
	MOVWF	clkcnt

	MOVLW	0			;Recall pin code
	CALL	prmget
	MOVWF	pin0
	MOVLW	1
	CALL	prmget
	MOVWF	pin1
	MOVLW	2
	CALL	prmget
	MOVWF	pin2
	MOVLW	3
	CALL	prmget
	MOVWF	pin3

	MOVLW	4			;Recall included/excluded zones
	CALL	prmget
	MOVWF	inclzone
	BSF	inclzone,7		;Ensure bit 7 (1st panic zone) is always on

	MOVLW	5			;Recall entry/exit zone
	CALL	prmget
	MOVWF	exitzone
	MOVLW	6			;Recall entry/exit time
	CALL	prmget
	MOVWF	exittime
	MOVLW	7			;Recall alarmzone status
	CALL	prmget
	MOVWF	alarmzone
	MOVLW	8			;Recall alarmstatus status
	CALL	prmget
	MOVWF	alarmstatus		;And activate buzzer/strobe if needed (but not bell)
	ANDLW	B'00000011'
	MOVWF	porte
	MOVLW	9			;Recall bell on time
	CALL	prmget
	MOVWF	belltime
	MOVLW	D'10'			;Recall "normal zone status
	CALL	prmget
	MOVWF	zonenormal

	MOVLW	D'11'			;Recall pin code 2
	CALL	prmget
	MOVWF	pin4
	MOVLW	D'12'
	CALL	prmget
	MOVWF	pin5
	MOVLW	D'13'
	CALL	prmget
	MOVWF	pin6
	MOVLW	D'14'
	CALL	prmget
	MOVWF	pin7

	MOVLW	D'15'			;Recall entry time for keypad2
	CALL	prmget
	MOVWF	entrytime2

	BTFSS	alarmstatus,7		;Is alarm on?
	GOTO	itsoff
	CALL	checkzone2
	BSF	alarmstatus,6		;Set power interruption flag
	GOTO	main

itsoff	
	CALL	alarmoff		;Show alarm off message
	BTFSC	engineerset,0		;Has engineer been called?
	GOTO	main			;Yes

	CALL	lcd21			;Set address for line 1 cell 1
	BSF	rsline,4		;Set rs for data send
Note, is a long code so chopped some off, just so you can see a sample conversion.
Format on converted MPASM is better than shown above. Code box appears to align text differently

Re: Upgrade from Version 2 PIC development boards

Posted: Mon Jan 31, 2011 10:21 am
by CornwallCollege
Many thanks for the ideas. We've now gone down the route of simply writing all our code in MPASM - as most of our examples used with students are failry short, it shouldn't take too long.