Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Substituting a 16x2 LCD display for 16x1 LCD display?

Status
Not open for further replies.

Dawny

Member
Hello again.

Sorry to bug you all again so soon but, does anyone know if I can substitute a 16x2 LCD display when a PIC circuit calls for a 16x1 LCD display?

Thanks in advance.


Dawn
 

Pommie

Well-Known Member
Most Helpful Member
Yes you can and it will just use the top line unless you modify the code. Do you have access to the source code?

Mike.
 

Dawny

Member
Yea most likely I do have access to the source code but at the moment editing would be far beyond what I can do...

Dawn
 

ericgibbs

Well-Known Member
Most Helpful Member
Dawny said:
Yea most likely I do have access to the source code but at the moment editing would be far beyond what I can do...

Dawn

If you need a little help, post your existing code, together with a note covering the small changes you would to make to it.:)
 

Dawny

Member
To be honest I'm not sure who wrote this code but the code I'm using is as follows...

;********************************************
; PFC-50 POCKET FREQUENCY COUNTER
;********************************************
;
;WATCHDOG DISABLED
;
;**********************************************************
LIST P=16F84A
#include <p16F84A.inc>
__CONFIG _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_ALL
;**********************************************************




RS EQU 2H
RW EQU 1H
E EQU 0H
O EQU 7H
;
COUNT1 EQU 2CH
COUNT2 EQU 2DH
IN_REG EQU 2EH
ADDCNT EQU 2FH
GATE EQU 0CH
CNT1 EQU 0DH
CNT2 EQU 0EH
CNT3 EQU 0FH
CALC1 EQU 10H
CALC2 EQU 11H
CALC3 EQU 12H
SUM1 EQU 13H
SUM2 EQU 14H
SUM3 EQU 15H
RTCC2 EQU 16H
TEMP1 EQU 17H
TEMP2 EQU 18H
COUNT3 EQU 19H
COUNT4 EQU 1AH

;-----------------------------------------------
;-----------------------------------------------
;-----------------------------------------------
ORG 0
GOTO START

;
INT_DEL:
MOVLW 0X05 ;DELAY 5.000 MS (4 MHZ CLOCK)
MOVWF COUNT1
D1 MOVLW 0XA5
MOVWF COUNT2
D2 DECFSZ COUNT2,F
GOTO D2
DECFSZ COUNT1,F
GOTO D1
RETLW 0X00
;
MIRROR:
CLRF TEMP2
MOVWF TEMP1
BTFSC TEMP1,0
BSF TEMP2,7
BTFSC TEMP1,1
BSF TEMP2,6
BTFSC TEMP1,2
BSF TEMP2,5
BTFSC TEMP1,3
BSF TEMP2,4
BTFSC TEMP1,4
BSF TEMP2,3
BTFSC TEMP1,5
BSF TEMP2,2
BTFSC TEMP1,6
BSF TEMP2,1
BTFSC TEMP1,7
BSF TEMP2,0
MOVF TEMP2,W
RETURN
;
LCD_OUT:
CALL MIRROR
MOVWF PORTB ;LOAD DATA INTO PORTB
BSF STATUS,RP0
MOVLW B'00000000' ;DEFINE PORTB AS OUTPUT
MOVWF TRISB
BCF STATUS,RP0
BSF PORTA,RS ;RS = DATA
BCF PORTA,RW ;R/W = WRITE
BSF PORTA,E ;TOGGLE ENABLE
BCF PORTA,E
;
BSF STATUS,RP0
MOVLW B'11111111' ;DEFINE PORTB AS INPUT
MOVWF TRISB
BCF STATUS,RP0
;
BCF PORTA,RS ;RS = INSTRUCTION
BSF PORTA,RW ;R/W = READ
BSF PORTA,E ;ENABLE HIGH
MOVF PORTB,W ;GET ADDRESS COUNTER
CALL MIRROR
MOVWF ADDCNT
BSF ADDCNT,7
BCF PORTA,E ;ENABLE LOW
OUT1 BSF PORTA,E ;ENABLE HIGH
BTFSS PORTB,0 ;TEST BUSY FLAG
GOTO OUT2
BCF PORTA,E ;ENABLE LOW
GOTO OUT1
OUT2 BCF PORTA,E ;ENABLE LOW
GOTO SHIFT
;
INST:
CALL MIRROR
MOVWF PORTB ;LOAD INSTRUCTION INTO PORTB
BSF STATUS,RP0
MOVLW B'00000000' ;DEFINE PORTB AS OUTPUT
MOVWF TRISB
BCF STATUS,RP0
BCF PORTA,RS ;RS = INSTRUCTION
BCF PORTA,RW ;R/W = WRITE
BSF PORTA,E ;TOGGLE ENABLE
BCF PORTA,E
BSF STATUS,RP0
MOVLW B'11111111' ;DEFINE PORTB AS INPUT
MOVWF TRISB
BCF STATUS,RP0
BSF PORTA,RW ;R/W = READ
INST1:
BSF PORTA,E ;ENABLE HIGH
BTFSS PORTB,0 ;TEST BUSY FLAG
GOTO INST2
BCF PORTA,E ;ENABLE LOW
GOTO INST1
INST2:
BCF PORTA,E ;ENABLE LOW
RETLW 0X00
;
;-----------------------------------
; LCD 16X1

SHIFT:
BTFSS ADDCNT,0 ;SHIFT TO OPPOSITE SIDE OF DISPLAY?
RETLW 0X00
BTFSS ADDCNT,1
RETLW 0X00
BTFSS ADDCNT,2
RETLW 0X00

MOVLW 0XC0
MOVF ADDCNT,W
MOVLW 0XC0
GOTO INST
;------------------------------------
SUB BCF STATUS,O ;CLEAR OVERFLOW BIT
MOVF CALC1,W ;SUBTRACT CALC1 FROM CNT1
SUBWF CNT1 ,F
BTFSC STATUS,C
GOTO SB1
MOVLW 0X01 ;BORROW FROM CNT2 IF OVERFLOW
SUBWF CNT2 ,F
BTFSC STATUS,C
GOTO SB1
SUBWF CNT3 ,F ;BORROW FROM CNT3 IF CNT2 OVERFLOW
BTFSS STATUS,C
BSF STATUS,O ;SET OVERFLOW BIT IF RESULT IS NEGATIVE
SB1 MOVF CALC2,W ;SUBTRACT CALC2 FROM CNT2
SUBWF CNT2 ,F
BTFSC STATUS,C
GOTO SB2
MOVLW 0X01 ;BORROW FROM CNT3 IF CNT2 OVERFLOW
SUBWF CNT3 ,F
BTFSS STATUS,C
BSF STATUS,O ;SET OVERFLOW BIT IF RESULT IS NEGATIVE
SB2 MOVF CALC3,W ;SUBTRACT CALC3 FROM CNT3
SUBWF CNT3 ,F
BTFSS STATUS,C
BSF STATUS,O ;SET OVERFLOW BIT IF RESULT IS NEGATIVE
RETLW 0X00
;-----------------------------------
ADD MOVF CALC1,W ;ADD CALC1 TO CNT1
ADDWF CNT1 ,F
BTFSS STATUS,C
GOTO AD1
INCFSZ CNT2 ,F ;ADD TO CNT2 IF CNT1 OVERFLOW
GOTO AD1
INCF CNT3 ,F ;ADD TO CNT3 IF CNT2 OVERFLOW
AD1 MOVF CALC2,W ;ADD CALC2 TO CNT2
ADDWF CNT2 ,F
BTFSC STATUS,C
INCF CNT3 ,F ;ADD TO CNT3 IF CNT2 OVERFLOW
MOVF CALC3,W ;ADD CALC3 TO CNT3
ADDWF CNT3 ,F
RETLW 0X00
;-----------------------------------
CNVT MOVLW 0X07 ;7 DIGITS IN DISPLAY
MOVWF COUNT1
MOVLW 0X19 ;SET FSR FOR MSB IN DISPLAY
MOVWF FSR
MOVLW 0X2F ;ONE LESS THAT ASCII "0"
CNVT0:
MOVWF INDF
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO CNVT0
MOVLW 0X0F ;LOAD "1,000,000" IN CALC1-3
MOVWF CALC3
MOVLW 0X42
MOVWF CALC2
MOVLW 0X40
MOVWF CALC1
CNVT1:
CALL SUB ;SUBTRACT NUMBER FROM COUNT
INCF 19 ,F ;INCREMENT 1,000,000'S REGISTER
MOVLW 0X3A
XORWF 19,W
BTFSC STATUS,Z
GOTO OVERFLOW
BTFSS STATUS,O ;CHECK IF OVERFLOW
GOTO CNVT1
CALL ADD ;ADD BACK LAST NUMBER
MOVLW 0X01 ;LOAD "100,000" IN CALC1-3
MOVWF CALC3
MOVLW 0X86
MOVWF CALC2
MOVLW 0XA0
MOVWF CALC1
CNVT2:
CALL SUB ;SUBTRACT NUMBER FROM COUNT
INCF 1A ,F ;INCREMENT 100,000'S REGISTER
BTFSS STATUS,O ;CHECK IF OVERFLOW
GOTO CNVT2
CALL ADD ;ADD BACK LAST NUMBER
CLRF CALC3 ;LOAD "10,000" IN CALC1-3
MOVLW 0X27
MOVWF CALC2
MOVLW 0X10
MOVWF CALC1
CNVT3:
CALL SUB ;SUBTRACT NUMBER FROM COUNT
INCF 1B ,F ;INCREMENT 10,000'S REGISTER
BTFSS STATUS,O ;CHECK IF OVERFLOW
GOTO CNVT3
CALL ADD ;ADD BACK LAST NUMBER
MOVLW 0X03 ;LOAD "1,000" IN CALC1-3
MOVWF CALC2
MOVLW 0XE8
MOVWF CALC1
CNVT4:
CALL SUB ;SUBTRACT NUMBER FROM COUNT
INCF 1C ,F ;INCREMENT 1,000'S REGISTER
BTFSS STATUS,O ;CHECK IF OVERFLOW
GOTO CNVT4
CALL ADD ;ADD BACK LAST NUMBER
CLRF CALC2 ;LOAD "100" IN CALC1-3
MOVLW 0X64
MOVWF CALC1
CNVT5:
CALL SUB ;SUBTRACT NUMBER FROM COUNT
INCF 1D ,F ;INCREMENT 100'S REGISTER
BTFSS STATUS,O ;CHECK IF OVERFLOW
GOTO CNVT5
CALL ADD ;ADD BACK NUMBER
MOVLW 0X0A ;LOAD "10" IN CALC1-3
MOVWF CALC1
CNVT6:
CALL SUB ;SUBTRACT NUMBER FROM COUNT
INCF 1E ,F ;INCREMENT 10'S REGISTER
BTFSS STATUS,O ;CHECK IF OVERFLOW
GOTO CNVT6
CALL ADD ;ADD BACK LAST NUMBER
MOVF CNT1,W ;PUT REMAINDFER IN 1'S REGISTER
ADDWF 1F ,F
INCF 1F ,F
RETLW 0X00
;-----------------------------------
COUNT:
BSF STATUS,RP0
MOVLW B'00110111' ;TMR0 = EXT, 1/256
MOVWF OPTION_REG
MOVLW B'00010000' ;DEFINE PORTA AS OUTPUT
MOVWF TRISA
BCF STATUS,RP0
BCF PORTA,3
BCF PORTA,2
CLRF CNT3
CLRF TMR0
CLRF RTCC2
BSF PORTA,2 ;TOGGLE TMR0 PIN
BCF PORTA,2
MOVF GATE,W ;GET GATE TIME
MOVWF COUNT1
BSF PORTA,3 ;START COUNT
FR4 MOVLW 0XFA
MOVWF COUNT2
GOTO FR6
FR5 NOP
NOP
NOP
NOP
NOP
NOP
FR6 MOVF TMR0,W ;TEST FOR TMR0 ROLLOVER (12)
SUBWF RTCC2 ,F
BTFSS STATUS,Z
GOTO FR7
NOP
GOTO FR8
FR7 BTFSC STATUS,C
INCF CNT3 ,F
FR8 MOVWF RTCC2
NOP
NOP
NOP
DECFSZ COUNT2 ,F
GOTO FR5
DECFSZ COUNT1 ,F
GOTO FR4
BCF PORTA,3 ;STOP COUNT
MOVF TMR0,W ;GET TMR0 COUNT
MOVWF CNT2
SUBWF RTCC2 ,F ;TEST FOR TMR0 ROLLOVER
BTFSS STATUS,C
GOTO FR9
BTFSS STATUS,Z
INCF CNT3 ,F
FR9 CLRF CNT1 ;SET TO GET PRESCALER COUNT
FR10 DECF CNT1 ,F
BSF PORTA,2 ;TOGGLE TMR0 PIN
BCF PORTA,2
MOVF TMR0,W ;TEST IF TMR0 HAS CHANGED
XORWF CNT2,W
BTFSC STATUS,Z
GOTO FR10
RETLW 0X00
;
;*********************************************************
; START MAIN PROGRAM
;*********************************************************
;
START:

CLRF PORTA ;INSTRUCTION, WRITE, ENABLE LOW
CLRF PORTB
;
BSF STATUS,RP0
MOVLW B'00010000'
MOVWF TRISA
MOVLW B'00000000'
MOVWF TRISB
BCF STATUS,RP0

CALL INT_DEL
CALL INT_DEL
CALL INT_DEL
;
MOVLW 0X38 ;INITIALIZE DISPLAY
CALL MIRROR
MOVWF PORTB
;
BSF PORTA,E ;TOGGLE ENABLE
CALL INT_DEL
BCF PORTA,E
BSF PORTA,E ;TOGGLE ENABLE
CALL INT_DEL
BCF PORTA,E
BSF PORTA,E ;TOGGLE ENABLE
CALL INT_DEL
BCF PORTA,E
;
MOVLW 0X38 ;FUNCTION
CALL INST
MOVLW B'00001100' ;DISPLAY ON, CURSOR OFF
CALL INST
MOVLW B'00000001' ;CLEAR DISPLAY
CALL INST
MOVLW B'00000110' ;ENTRY MODE
CALL INST
;
;***********************************
; NEW LINES HERE FOR INTRO
MOVLW 0X50 ;P
CALL LCD_OUT
MOVLW 0X46 ;F
CALL LCD_OUT
MOVLW 0X43 ;C
CALL LCD_OUT
MOVLW 0X2D ;-
CALL LCD_OUT
MOVLW 0X35 ;5
CALL LCD_OUT
MOVLW 0X30 ;0
CALL LCD_OUT
;
MOVLW 0X06 ;CHANGE THE 6 TO A SMALLER NO. TO SPEED UP THE INTRO
MOVWF COUNT3
WAIT1:
MOVLW 0XC8
MOVWF COUNT4
WAIT2:
CALL INT_DEL
DECFSZ COUNT4 ,F
GOTO WAIT2
DECFSZ COUNT3 ,F
GOTO WAIT1
;************************************
MOVLW B'00000001' ;CLEAR DISPLAY
CALL INST
;
MHZ MOVLW 0X14 ;0.1 SEC GATE
MOVWF GATE
CALL COUNT
CALL CNVT ;CONVERT BINARY TO BCD
MOVLW 0X30 ;TEST IF "0"
XORWF 19,W
BTFSS STATUS,Z
GOTO MHZ1
MOVLW 0X30 ;TEST IF "0"
XORWF 1A,W
BTFSC STATUS,Z
GOTO KHZ1
MHZ1 MOVLW 0X82 ;SET DISPLAY ADDRESS
CALL INST
MOVLW 0X02 ;OUTPUT FIRST 2 CHARACTERS
MOVWF COUNT1
MOVLW 0X19 ;MSD OF FREQ
MOVWF FSR
MHZ2 MOVLW 0X30 ;TEST IF "0"
XORWF INDF,W
BTFSS STATUS,Z
GOTO MHZ3
MOVLW 0X20 ;CHANGE PRECEEDING "0'S" TO "SPACE"
CALL LCD_OUT
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO MHZ2
GOTO MHZ4
MHZ3 MOVF INDF,W
CALL LCD_OUT
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO MHZ3
MHZ4 MOVLW 0X2E ;"."
CALL LCD_OUT
MOVLW 0X05 ;OUTPUT LAST 5 CHARACTERS
MOVWF COUNT1
MHZ5 MOVF INDF,W
CALL LCD_OUT
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO MHZ5
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X4D ;"M"
CALL LCD_OUT
MOVLW 0X48 ;"H"
CALL LCD_OUT
MOVLW 0X7A ;"Z"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
GOTO MHZ
;-----------------------------------
KHZ MOVLW 0X14 ;0.1 SEC GATE
MOVWF GATE
CALL COUNT
CALL CNVT ;CONVERT BINARY TO BCD
MOVLW 0X30 ;TEST IF 0
XORWF 19,W
BTFSS STATUS,Z
GOTO MHZ1
MOVLW 0X32 ;TEST IF < 2
SUBWF 1A,W
BTFSC STATUS,C
GOTO MHZ1
MOVLW 0X30 ;TEST IF "0"
XORWF 1A,W
BTFSS STATUS,Z
GOTO KHZ1
MOVLW 0X30 ;TEST IF "0"
XORWF 1B,W
BTFSC STATUS,Z
GOTO XKHZ
KHZ1 MOVLW 0X82 ;SET DISPLAY ADDRESS
CALL INST
MOVLW 0X05 ;OUTPUT FIRST 5 CHARACTERS
MOVWF COUNT1
MOVLW 0X19 ;MSD OF FREQ
MOVWF FSR
KHZ2 MOVLW 0X30 ;TEST IF "0"
XORWF INDF,W
BTFSS STATUS,Z
GOTO KHZ3
MOVLW 0X20 ;CHANGE PRECEEDING "0'S" TO "SPACE"
CALL LCD_OUT
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO KHZ2
GOTO KHZ4
KHZ3 MOVF INDF,W
CALL LCD_OUT
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO KHZ3
KHZ4 MOVLW 0X2E ;"."
CALL LCD_OUT
MOVF INDF,W ;OUTPUT LAST 2 CHARACTERS
CALL LCD_OUT
INCF FSR ,F
MOVF INDF,W
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X4B ;"K"
CALL LCD_OUT
MOVLW 0X48 ;"H"
CALL LCD_OUT
MOVLW 0X7A ;"Z"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
GOTO KHZ
;-----------------------------------
XKHZ MOVLW 0XC8 ;1 SEC GATE
MOVWF GATE
CALL COUNT
CALL CNVT ;CONVERT BINARY TO BCD
MOVLW 0X30 ;TEST IF 0
XORWF 19,W
BTFSS STATUS,Z
GOTO KHZ
MOVLW 0X32 ;TEST IF < 2
SUBWF 1A,W
BTFSC STATUS,C
GOTO KHZ
MOVLW 0X30 ;TEST IF 0
XORWF 1A,W
BTFSS STATUS,Z
GOTO XKHZ1
MOVLW 0X30 ;TEST IF 0
XORWF 1B,W
BTFSC STATUS,Z
GOTO HZ0
XKHZ1:
MOVLW 0X82 ;SET DISPLAY ADDRESS
CALL INST
MOVLW 0X04 ;OUTPUT FIRST 4 CHARACTERS
MOVWF COUNT1
MOVLW 0X19 ;MSD OF FREQ
MOVWF FSR
XKHZ2:
MOVLW 0X30 ;TEST IF "0"
XORWF INDF,W
BTFSS STATUS,Z
GOTO XKHZ3
MOVLW 0X20 ;CHANGE PRECEEDING "0'S" TO "SPACE"
CALL LCD_OUT
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO XKHZ2
GOTO XKHZ4
XKHZ3:
MOVF INDF,W
CALL LCD_OUT
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO XKHZ3
XKHZ4:
MOVLW 0X2E ;"."
CALL LCD_OUT
MOVF INDF,W ;OUTPUT LAST 3 CHARACTERS
CALL LCD_OUT
INCF FSR ,F
MOVF INDF,W
CALL LCD_OUT
INCF FSR ,F
MOVF INDF,W
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X4B ;"K"
CALL LCD_OUT
MOVLW 0X48 ;"H"
CALL LCD_OUT
MOVLW 0X7A ;"Z"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
GOTO XKHZ
;-----------------------------------
HZ MOVLW 0XC8 ;1 SEC GATE
MOVWF GATE
CALL COUNT
CALL CNVT ;CONVERT BINARY TO BCD
MOVLW 0X30 ;TEST IF "0"
XORWF 19,W
BTFSS STATUS,Z
GOTO XKHZ1
MOVLW 0X30 ;TEST IF "0"
XORWF 1A,W
BTFSS STATUS,Z
GOTO XKHZ1
MOVLW 0X32 ;TEST IF < 2
SUBWF 1B,W
BTFSC STATUS,C
GOTO XKHZ1
HZ0 MOVLW 0X82 ;SET DISPLAY ADDRESS
CALL INST
MOVLW 0X07 ;OUTPUT FIRST 7 CHARACTERS
MOVWF COUNT1
MOVLW 0X19 ;MSD OF FREQ
MOVWF FSR
HZ1 MOVLW 0X30 ;TEST IF "0"
XORWF INDF,W
BTFSS STATUS,Z
GOTO HZ2
MOVLW 0X20 ;CHANGE PRECEEDING "0'S" TO "SPACE"
CALL LCD_OUT
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO HZ1
GOTO HZ3
HZ2 MOVF INDF,W
CALL LCD_OUT
INCF FSR ,F
DECFSZ COUNT1 ,F
GOTO HZ2
HZ3 MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X48 ;"H"
CALL LCD_OUT
MOVLW 0X7A ;"Z"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
MOVLW 0X20 ;"SPACE"
CALL LCD_OUT
GOTO HZ
;-----------------------------------
OVERFLOW:
MOVLW 0X01 ;CLEAR DISPLAY
CALL INST
MOVLW 0X84 ;DISPLAY ADDRESS
CALL INST
MOVLW 0X4F ;"O"
CALL LCD_OUT
MOVLW 0X76 ;"V"
CALL LCD_OUT
MOVLW 0X65 ;"E"
CALL LCD_OUT
MOVLW 0X72 ;"R"
CALL LCD_OUT
MOVLW 0X66 ;"F"
CALL LCD_OUT
MOVLW 0X6C ;"L"
CALL LCD_OUT
MOVLW 0X6F ;"O"
CALL LCD_OUT
MOVLW 0X77 ;"W"
CALL LCD_OUT
MOVLW 0X02 ;CURSOR AT HOME
CALL INST
GOTO MHZ
;-----------------------------------
END


The code is designed for a 16x1 display but all I have on hand is a 16x2 display I don't mind using the display with a blank line but at the moment the code displays half the output on one line and half on the other so lets say you are mesuring a frequance of 3002 Hz it will display it as something like:

Freq: 3
002 Hz

I'm looking for a way to make the code display everything on one line but don't know enough yet to re-write the code to do so...

Dawn.

P.S. Thanks in advance.
 

Pommie

Well-Known Member
Most Helpful Member
Hi Dawn,

It looks like the code was intended to be used with a display that is arranged as a 2*8 but with one line following the other.

The way to fix it is to put a return instruction on the line with the label SHIFT:

I.E.
Code:
SHIFT:    return

I can probably work out how to make it display
PFC-50
Freq: 3002 Hz

If you think it would be worth it.

Mike.


Mike.
 

ericgibbs

Well-Known Member
Most Helpful Member
hi Dawn,

Mike has already answered your query, so I will not add my four penny worth.

Looks an interesting bit of code, you must let us know how the program changes go.:)

A suggestion would be, when you post program code after you have placed it in the text window, SELECT the code, then use the menu at the top of the window, click the # symbol [wrap code tags].
This will display all your code including the formatting.

Anyone wishing to run your program, just has to copy and paste, OK.

Hope that makes sense.
 

mvs sarma

Well-Known Member
ericgibbs said:
hi Dawn,

Mike has already answered your query, so I will not add my four penny worth.

Looks an interesting bit of code, you must let us know how the program changes go.:)

A suggestion would be, when you post program code after you have placed it in the text window, SELECT the code, then use the menu at the top of the window, click the # symbol [wrap code tags].
This will display all your code including the formatting.

Anyone wishing to run your program, just has to copy and paste, OK.

Hope that makes sense.

To be of help to others, here is the code
Code:
;******************************************** 
; PFC-50 POCKET FREQUENCY COUNTER 
;******************************************** 
; 
;WATCHDOG DISABLED 
; 
;********************************************************** 
	LIST P=16F84A 
	#include <p16F84A.inc> 
	__CONFIG _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF 
	errorlevel -302
;********************************************************** 
	 
 
 
 
RS EQU 2H 
RW EQU 1H 
E EQU 0H 
O EQU 7H 
; 
COUNT1 EQU 2CH 
COUNT2 EQU 2DH 
IN_REG EQU 2EH 
ADDCNT EQU 2FH 
GATE EQU 0CH 
CNT1 EQU 0DH 
CNT2 EQU 0EH 
CNT3 EQU 0FH 
CALC1 EQU 10H 
CALC2 EQU 11H 
CALC3 EQU 12H 
SUM1 EQU 13H 
SUM2 EQU 14H 
SUM3 EQU 15H 
RTCC2 EQU 16H 
TEMP1 EQU 17H 
TEMP2 EQU 18H 
COUNT3 EQU 19H 
COUNT4 EQU 1AH 
 
;----------------------------------------------- 
;----------------------------------------------- 
;----------------------------------------------- 
	ORG 0 
	GOTO START 
 
; 
INT_DEL: 
	MOVLW 	0X05 			;DELAY 5.000 MS (4 MHZ CLOCK) 
	MOVWF 	COUNT1 
D1 	MOVLW 	0XA5 
	MOVWF 	COUNT2 
D2 DECFSZ 	COUNT2,F 
	GOTO 	D2 
	DECFSZ 	COUNT1,F 
	GOTO 	D1 
	RETLW 	0X00 
; 
MIRROR: 
	CLRF 	TEMP2 
	MOVWF 	TEMP1 
	BTFSC 	TEMP1,0 
	BSF 	TEMP2,7 
	BTFSC 	TEMP1,1 
	BSF 	TEMP2,6 
	BTFSC 	TEMP1,2 
	BSF 	TEMP2,5 
	BTFSC 	TEMP1,3 
	BSF 	TEMP2,4 
	BTFSC 	TEMP1,4 
	BSF 	TEMP2,3 
	BTFSC 	TEMP1,5 
	BSF 	TEMP2,2 
	BTFSC 	TEMP1,6 
	BSF 	TEMP2,1 
	BTFSC 	TEMP1,7 
	BSF 	TEMP2,0 
	MOVF 	TEMP2,W 
	RETURN 
; 
LCD_OUT: 
	CALL 	MIRROR 
	MOVWF 	PORTB 			;LOAD DATA INTO PORTB 
	BSF 	STATUS,RP0 
	MOVLW 	B'00000000' 	;DEFINE PORTB AS OUTPUT 
	MOVWF 	TRISB 
	BCF 	STATUS,RP0 
	BSF 	PORTA,RS 		;RS = DATA 
	BCF 	PORTA,RW 		;R/W = WRITE 
	BSF 	PORTA,E 		;TOGGLE ENABLE 
	BCF 	PORTA,E 
; 
	BSF 	STATUS,RP0 
	MOVLW 	B'11111111' 	;DEFINE PORTB AS INPUT 
	MOVWF 	TRISB 
	BCF 	STATUS,RP0 
; 
	BCF 	PORTA,RS 		;RS = INSTRUCTION 
	BSF 	PORTA,RW 		;R/W = READ 
	BSF 	PORTA,E 		;ENABLE HIGH 
	MOVF 	PORTB,W 		;GET ADDRESS COUNTER 
	CALL 	MIRROR 
	MOVWF 	ADDCNT 
	BSF 	ADDCNT,7 
	BCF 	PORTA,E 		;ENABLE LOW 
OUT1 BSF 	PORTA,E 		;ENABLE HIGH 
	BTFSS 	PORTB,0 		;TEST BUSY FLAG 
	GOTO 	OUT2 
	BCF 	PORTA,E 		;ENABLE LOW 
	GOTO 	OUT1 
OUT2 BCF 	PORTA,E 		;ENABLE LOW 
	GOTO 	SHIFT 
; 
INST: 
	CALL 	MIRROR 
	MOVWF 	PORTB 			;LOAD INSTRUCTION INTO PORTB 
	BSF 	STATUS,RP0 
	MOVLW 	B'00000000' 	;DEFINE PORTB AS OUTPUT 
	MOVWF 	TRISB 
	BCF 	STATUS,RP0 
	BCF 	PORTA,RS 		;RS = INSTRUCTION 
	BCF 	PORTA,RW 		;R/W = WRITE 
	BSF 	PORTA,E 		;TOGGLE ENABLE 
	BCF 	PORTA,E 
	BSF 	STATUS,RP0 
	MOVLW 	B'11111111' 	;DEFINE PORTB AS INPUT 
	MOVWF 	TRISB 
	BCF 	STATUS,RP0 
	BSF 	PORTA,RW 		;R/W = READ 
INST1: 
	BSF 	PORTA,E         ;ENABLE HIGH 
	BTFSS 	PORTB,0 		;TEST BUSY FLAG 
	GOTO 	INST2 
	BCF 	PORTA,E 		;ENABLE LOW 
	GOTO 	INST1 
INST2: 
	BCF 	PORTA,E 		;ENABLE LOW 
	RETLW 	0X00 
; 
;----------------------------------- 
; LCD 16X1 
 
SHIFT: 
	BTFSS 	ADDCNT,0 		;SHIFT TO OPPOSITE SIDE OF DISPLAY? 
	RETLW 	0X00 
	BTFSS 	ADDCNT,1 
	RETLW 	0X00 
	BTFSS 	ADDCNT,2 
	RETLW 	0X00 
 
	MOVLW 	0XC0 
	MOVF 	ADDCNT,W 
	MOVLW 	0XC0 
	GOTO 	INST 
;------------------------------------ 
SUB BCF 	STATUS,O 		;CLEAR OVERFLOW BIT 
	MOVF 	CALC1,W 		;SUBTRACT CALC1 FROM CNT1 
	SUBWF 	CNT1 ,F 
	BTFSC 	STATUS,C 
	GOTO 	SB1 
	MOVLW 	0X01 			;BORROW FROM CNT2 IF OVERFLOW 
	SUBWF 	CNT2 ,F 
	BTFSC 	STATUS,C 
	GOTO 	SB1 
	SUBWF 	CNT3 ,F 		;BORROW FROM CNT3 IF CNT2 OVERFLOW 
	BTFSS 	STATUS,C 
	BSF 	STATUS,O 		;SET OVERFLOW BIT IF RESULT IS NEGATIVE 
SB1 MOVF 	CALC2,W 		;SUBTRACT CALC2 FROM CNT2 
	SUBWF 	CNT2 ,F 
	BTFSC 	STATUS,C 
	GOTO 	SB2 
	MOVLW 	0X01 			;BORROW FROM CNT3 IF CNT2 OVERFLOW 
	SUBWF 	CNT3 ,F 
	BTFSS 	STATUS,C 
	BSF 	STATUS,O 		;SET OVERFLOW BIT IF RESULT IS NEGATIVE 
SB2 MOVF 	CALC3,W 		;SUBTRACT CALC3 FROM CNT3 
	SUBWF 	CNT3 ,F 
	BTFSS 	STATUS,C 
	BSF 	STATUS,O 		;SET OVERFLOW BIT IF RESULT IS NEGATIVE 
	RETLW 	0X00 
;----------------------------------- 
ADD MOVF 	CALC1,W 		;ADD CALC1 TO CNT1 
	ADDWF 	CNT1 ,F 
	BTFSS 	STATUS,C 
	GOTO 	AD1 
	INCFSZ 	CNT2 ,F 		;ADD TO CNT2 IF CNT1 OVERFLOW 
	GOTO 	AD1 
	INCF 	CNT3 ,F 		;ADD TO CNT3 IF CNT2 OVERFLOW 
AD1 MOVF 	CALC2,W 		;ADD CALC2 TO CNT2 
	ADDWF 	CNT2 ,F 
	BTFSC 	STATUS,C 
	INCF 	CNT3 ,F 		;ADD TO CNT3 IF CNT2 OVERFLOW 
	MOVF 	CALC3,W 		;ADD CALC3 TO CNT3 
	ADDWF 	CNT3 ,F 
	RETLW 	0X00 
;----------------------------------- 
CNVT MOVLW 	0X07 			;7 DIGITS IN DISPLAY 
	MOVWF 	COUNT1 
	MOVLW 	0X19 			;SET FSR FOR MSB IN DISPLAY 
	MOVWF 	FSR 
	MOVLW 	0X2F 			;ONE LESS THAT ASCII "0" 
CNVT0: 
	MOVWF 	INDF 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	CNVT0 
	MOVLW 	0X0F 			;LOAD "1,000,000" IN CALC1-3 
	MOVWF 	CALC3 
	MOVLW 	0X42 
	MOVWF 	CALC2 
	MOVLW 	0X40 
	MOVWF 	CALC1 
CNVT1: 
	CALL 	SUB 			;SUBTRACT NUMBER FROM COUNT 
	INCF 	19 ,F 			;INCREMENT 1,000,000'S REGISTER 
	MOVLW 	0X3A 
	XORWF 	19,W 
	BTFSC 	STATUS,Z 
	GOTO 	OVERFLOW 
	BTFSS 	STATUS,O 		;CHECK IF OVERFLOW 
	GOTO 	CNVT1 
	CALL 	ADD 			;ADD BACK LAST NUMBER 
	MOVLW 	0X01 			;LOAD "100,000" IN CALC1-3 
	MOVWF 	CALC3 
	MOVLW 	0X86 
	MOVWF 	CALC2 
	MOVLW 	0XA0 
	MOVWF 	CALC1 
CNVT2: 
	CALL 	SUB 			;SUBTRACT NUMBER FROM COUNT 
	INCF 	1A ,F 			;INCREMENT 100,000'S REGISTER 
	BTFSS 	STATUS,O 		;CHECK IF OVERFLOW 
	GOTO 	CNVT2 
	CALL 	ADD 			;ADD BACK LAST NUMBER 
	CLRF 	CALC3 			;LOAD "10,000" IN CALC1-3 
	MOVLW 	0X27 
	MOVWF 	CALC2 
	MOVLW 	0X10 
	MOVWF 	CALC1 
CNVT3: 
	CALL 	SUB 			;SUBTRACT NUMBER FROM COUNT 
	INCF 	1B ,F 			;INCREMENT 10,000'S REGISTER 
	BTFSS 	STATUS,O 		;CHECK IF OVERFLOW 
	GOTO 	CNVT3 
	CALL 	ADD 			;ADD BACK LAST NUMBER 
	MOVLW 	0X03 			;LOAD "1,000" IN CALC1-3 
	MOVWF 	CALC2 
	MOVLW 	0XE8 
	MOVWF 	CALC1 
CNVT4: 
	CALL 	SUB 			;SUBTRACT NUMBER FROM COUNT 
	INCF 	1C ,F 			;INCREMENT 1,000'S REGISTER 
	BTFSS 	STATUS,O 		;CHECK IF OVERFLOW 
	GOTO 	CNVT4 
	CALL 	ADD 			;ADD BACK LAST NUMBER 
	CLRF 	CALC2 			;LOAD "100" IN CALC1-3 
	MOVLW 	0X64 
	MOVWF 	CALC1 
CNVT5: 
	CALL 	SUB 			;SUBTRACT NUMBER FROM COUNT 
	INCF 	1D ,F 			;INCREMENT 100'S REGISTER 
	BTFSS 	STATUS,O 		;CHECK IF OVERFLOW 
	GOTO 	CNVT5 
	CALL 	ADD 			;ADD BACK NUMBER 
	MOVLW 	0X0A 			;LOAD "10" IN CALC1-3 
	MOVWF 	CALC1 
CNVT6: 
	CALL 	SUB 			;SUBTRACT NUMBER FROM COUNT 
	INCF 	1E ,F 			;INCREMENT 10'S REGISTER 
	BTFSS 	STATUS,O 		;CHECK IF OVERFLOW 
	GOTO 	CNVT6 
	CALL 	ADD 			;ADD BACK LAST NUMBER 
	MOVF 	CNT1,W 			;PUT REMAINDFER IN 1'S REGISTER 
	ADDWF 	1F ,F 
	INCF 	1F ,F 
	RETLW 	0X00 
;----------------------------------- 
COUNT: 
	BSF 	STATUS,RP0 
	MOVLW 	B'00110111' 	;TMR0 = EXT, 1/256 
	MOVWF 	OPTION_REG 
	MOVLW 	B'00010000'  	;DEFINE PORTA AS OUTPUT 
	MOVWF 	TRISA 
	BCF 	STATUS,RP0 
	BCF 	PORTA,3 
	BCF 	PORTA,2 
	CLRF 	CNT3 
	CLRF 	TMR0 
	CLRF 	RTCC2 
	BSF 	PORTA,2 		;TOGGLE TMR0 PIN 
	BCF 	PORTA,2 
	MOVF 	GATE,W 			;GET GATE TIME 
	MOVWF 	COUNT1 
	BSF 	PORTA,3 		;START COUNT 
FR4 MOVLW 	0XFA 
	MOVWF 	COUNT2 
	GOTO 	FR6 
FR5 NOP 
	NOP 
	NOP 
	NOP 
	NOP 
	NOP 
FR6 MOVF 	TMR0,W 			;TEST FOR TMR0 ROLLOVER (12) 
	SUBWF 	RTCC2 ,F 
	BTFSS 	STATUS,Z 
	GOTO 	FR7 
	NOP 
	GOTO 	FR8 
FR7 BTFSC 	STATUS,C 
	INCF 	CNT3 ,F 
FR8 MOVWF 	RTCC2 
	NOP 
	NOP 
	NOP 
	DECFSZ 	COUNT2 ,F 
	GOTO 	FR5 
	DECFSZ 	COUNT1 ,F 
	GOTO 	FR4 
	BCF 	PORTA,3 		;STOP COUNT 
	MOVF 	TMR0,W 			;GET TMR0 COUNT 
	MOVWF 	CNT2 
	SUBWF 	RTCC2 ,F 		;TEST FOR TMR0 ROLLOVER 
	BTFSS 	STATUS,C 
	GOTO 	FR9 
	BTFSS 	STATUS,Z 
	INCF 	CNT3 ,F 
FR9 CLRF 	CNT1 			;SET TO GET PRESCALER COUNT 
FR10 DECF 	CNT1 ,F 
	BSF 	PORTA,2 		;TOGGLE TMR0 PIN 
	BCF 	PORTA,2 
	MOVF 	TMR0,W 			;TEST IF TMR0 HAS CHANGED 
	XORWF 	CNT2,W 
	BTFSC 	STATUS,Z 
	GOTO 	FR10 
	RETLW 	0X00 
; 
;************************************************* ******** 
; START MAIN PROGRAM 
;************************************************* ******** 
; 
START: 
 
	CLRF 	PORTA 			;INSTRUCTION, WRITE, ENABLE LOW 
	CLRF 	PORTB 
; 
	BSF 	STATUS,RP0 
	MOVLW 	B'00010000' 
	MOVWF 	TRISA 
	MOVLW 	B'00000000' 
	MOVWF 	TRISB 
	BCF 	STATUS,RP0 
 
	CALL 	INT_DEL 
	CALL 	INT_DEL 
	CALL 	INT_DEL 
; 
	MOVLW 	0X38 			;INITIALIZE DISPLAY 
	CALL 	MIRROR 
	MOVWF 	PORTB 
; 
	BSF 	PORTA,E 		;TOGGLE ENABLE 
	CALL 	INT_DEL 
	BCF 	PORTA,E 
	BSF 	PORTA,E 		;TOGGLE ENABLE 
	CALL 	INT_DEL 
	BCF 	PORTA,E 
	BSF 	PORTA,E 		;TOGGLE ENABLE 
	CALL 	INT_DEL 
	BCF 	PORTA,E 
; 
	MOVLW 	0X38 			;FUNCTION 
	CALL 	INST 
	MOVLW 	B'00001100' 	;DISPLAY ON, CURSOR OFF 
	CALL 	INST 
	MOVLW 	B'00000001' 	;CLEAR DISPLAY 
	CALL 	INST 
	MOVLW 	B'00000110' 	;ENTRY MODE 
	CALL 	INST 
; 
;*********************************** 
; NEW LINES HERE FOR INTRO 
;*******************************
	MOVLW 	0X50 ;P 
	CALL 	LCD_OUT 
	MOVLW 	0X46 ;F 
	CALL 	LCD_OUT 
	MOVLW 	0X43 ;C 
	CALL 	LCD_OUT 
	MOVLW 	0X2D ;- 
	CALL 	LCD_OUT 
	MOVLW 	0X35 ;5 
	CALL 	LCD_OUT 
	MOVLW 	0X30 ;0 
	CALL 	LCD_OUT 
; 
	MOVLW 	0X06 			;CHANGE THE 6 TO A SMALLER NO. TO SPEED UP THE INTRO 
	MOVWF 	COUNT3 
WAIT1: 
	MOVLW 	0XC8 
	MOVWF 	COUNT4 
WAIT2: 
	CALL 	INT_DEL 
	DECFSZ 	COUNT4 ,F 
	GOTO 	WAIT2 
	DECFSZ 	COUNT3 ,F 
	GOTO 	WAIT1 
;************************************ 
	MOVLW 	B'00000001' 	;CLEAR DISPLAY 
	CALL 	INST 
; 
MHZ MOVLW 	0X14 			;0.1 SEC GATE 
	MOVWF 	GATE 
	CALL 	COUNT 
	CALL 	CNVT 			;CONVERT BINARY TO BCD 
	MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	19,W 
	BTFSS 	STATUS,Z 
	GOTO 	MHZ1 
	MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	1A,W 
	BTFSC 	STATUS,Z 
	GOTO 	KHZ1 
MHZ1 MOVLW 	0X82 			;SET DISPLAY ADDRESS 
	CALL 	INST 
	MOVLW 	0X02 			;OUTPUT FIRST 2 CHARACTERS 
	MOVWF 	COUNT1 
	MOVLW 	0X19 			;MSD OF FREQ 
	MOVWF 	FSR 
MHZ2 MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	INDF,W 
	BTFSS 	STATUS,Z 
	GOTO 	MHZ3 
	MOVLW 	0X20 			;CHANGE PRECEEDING "0'S" TO "SPACE" 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	MHZ2 
	GOTO 	MHZ4 
MHZ3 MOVF 	INDF,W 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	MHZ3 
MHZ4 MOVLW 	0X2E 			;"." 
	CALL 	LCD_OUT 
	MOVLW 	0X05 			;OUTPUT LAST 5 CHARACTERS 
	MOVWF 	COUNT1 
MHZ5 MOVF 	INDF,W 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	MHZ5 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X4D 			;"M" 
	CALL 	LCD_OUT 
	MOVLW 	0X48 			;"H" 
	CALL 	LCD_OUT 
	MOVLW 	0X7A ;"Z" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	GOTO 	MHZ 
;----------------------------------- 
KHZ MOVLW 	0X14 			;0.1 SEC GATE 
	MOVWF 	GATE 
	CALL 	COUNT 
	CALL 	CNVT 			;CONVERT BINARY TO BCD 
	MOVLW 	0X30 			;TEST IF 0 
	XORWF 	19,W 
	BTFSS 	STATUS,Z 
	GOTO 	MHZ1 
	MOVLW 	0X32 			;TEST IF < 2 
	SUBWF 	1A,W 
	BTFSC 	STATUS,C 
	GOTO 	MHZ1 
	MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	1A,W 
	BTFSS 	STATUS,Z 
	GOTO 	KHZ1 
	MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	1B,W 
	BTFSC 	STATUS,Z 
	GOTO 	XKHZ 
KHZ1 MOVLW 	0X82 			;SET DISPLAY ADDRESS 
	CALL 	INST 
	MOVLW 	0X05 			;OUTPUT FIRST 5 CHARACTERS 
	MOVWF 	COUNT1 
	MOVLW 	0X19 			;MSD OF FREQ 
	MOVWF 	FSR 
KHZ2 MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	INDF,W 
	BTFSS 	STATUS,Z 
	GOTO 	KHZ3 
	MOVLW 	0X20 			;CHANGE PRECEEDING "0'S" TO "SPACE" 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	KHZ2 
	GOTO 	KHZ4 
KHZ3 MOVF 	INDF,W 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	KHZ3 
KHZ4 MOVLW 	0X2E 			;"." 
	CALL 	LCD_OUT 
	MOVF 	INDF,W 			;OUTPUT LAST 2 CHARACTERS 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	MOVF 	INDF,W 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X4B 			;"K" 
	CALL 	LCD_OUT 
	MOVLW 	0X48 			;"H" 
	CALL 	LCD_OUT 
	MOVLW 	0X7A 			;"Z" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	GOTO 	KHZ 
;----------------------------------- 
XKHZ MOVLW 	0XC8 			;1 SEC GATE 
	MOVWF 	GATE 
	CALL 	COUNT 
	CALL 	CNVT   			;CONVERT BINARY TO BCD 
	MOVLW 	0X30 			;TEST IF 0 
	XORWF 	19,W 
	BTFSS 	STATUS,Z 
	GOTO 	KHZ 
	MOVLW 	0X32 			;TEST IF < 2 
	SUBWF 	1A,W 
	BTFSC 	STATUS,C 
	GOTO 	KHZ 
	MOVLW 	0X30 			;TEST IF 0 
	XORWF 	1A,W 
	BTFSS 	STATUS,Z 
	GOTO 	XKHZ1 
	MOVLW 	0X30 			;TEST IF 0 
	XORWF 	1B,W 
	BTFSC 	STATUS,Z 
	GOTO 	HZ0 
XKHZ1: 
	MOVLW 	0X82 			;SET DISPLAY ADDRESS 
	CALL 	INST 
	MOVLW 	0X04 			;OUTPUT FIRST 4 CHARACTERS 
	MOVWF 	COUNT1 
	MOVLW 	0X19 			;MSD OF FREQ 
	MOVWF 	FSR 
XKHZ2: 
	MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	INDF,W 
	BTFSS 	STATUS,Z 
	GOTO 	XKHZ3 
	MOVLW 	0X20 			;CHANGE PRECEEDING "0'S" TO "SPACE" 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	XKHZ2 
	GOTO 	XKHZ4 
XKHZ3: 
	MOVF 	INDF,W 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	XKHZ3 
XKHZ4: 
	MOVLW 	0X2E 			;"." 
	CALL 	LCD_OUT 
	MOVF 	INDF,W 			;OUTPUT LAST 3 CHARACTERS 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	MOVF 	INDF,W 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	MOVF 	INDF,W 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X4B 			;"K" 
	CALL 	LCD_OUT 
	MOVLW 	0X48 			;"H" 
	CALL 	LCD_OUT 
	MOVLW 	0X7A 			;"Z" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	GOTO 	XKHZ 
;----------------------------------- 
HZ MOVLW 	0XC8 			;1 SEC GATE 
	MOVWF	GATE 
	CALL 	COUNT 
	CALL 	CNVT 			;CONVERT BINARY TO BCD 
	MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	19,W 
	BTFSS 	STATUS,Z 
	GOTO 	XKHZ1 
	MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	1A,W 
	BTFSS 	STATUS,Z 
	GOTO 	XKHZ1 
	MOVLW 	0X32 			;TEST IF < 2 
	SUBWF 	1B,W 
	BTFSC 	STATUS,C 
	GOTO 	XKHZ1 
HZ0 MOVLW 	0X82 			;SET DISPLAY ADDRESS 
	CALL 	INST 
	MOVLW 	0X07 			;OUTPUT FIRST 7 CHARACTERS 
	MOVWF 	COUNT1 
	MOVLW 	0X19 			;MSD OF FREQ 
	MOVWF 	FSR 
HZ1 MOVLW 	0X30 			;TEST IF "0" 
	XORWF 	INDF,W 
	BTFSS 	STATUS,Z 
	GOTO 	HZ2 
	MOVLW 	0X20 			;CHANGE PRECEEDING "0'S" TO "SPACE" 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	HZ1 
	GOTO 	HZ3 
HZ2 MOVF 	INDF,W 
	CALL 	LCD_OUT 
	INCF 	FSR ,F 
	DECFSZ 	COUNT1 ,F 
	GOTO 	HZ2 
HZ3 MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X48 			;"H" 
	CALL 	LCD_OUT 
	MOVLW 	0X7A 			;"Z" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	MOVLW 	0X20 			;"SPACE" 
	CALL 	LCD_OUT 
	GOTO 	HZ 
;----------------------------------- 
OVERFLOW: 
	MOVLW 	0X01 			;CLEAR DISPLAY 
	CALL 	INST 
	MOVLW 	0X84 			;DISPLAY ADDRESS 
	CALL 	INST 
	MOVLW 	0X4F 			;"O" 
	CALL 	LCD_OUT 
	MOVLW 	0X76 			;"V" 
	CALL 	LCD_OUT 
	MOVLW 	0X65 			;"E" 
	CALL 	LCD_OUT 
	MOVLW 	0X72 			;"R" 
	CALL 	LCD_OUT 
	MOVLW 	0X66 			;"F" 
	CALL 	LCD_OUT 
	MOVLW 	0X6C 			;"L" 
	CALL 	LCD_OUT 
	MOVLW 	0X6F 			;"O" 
	CALL 	LCD_OUT 
	MOVLW 	0X77 			;"W" 
	CALL 	LCD_OUT 
	MOVLW 	0X02 			;CURSOR AT HOME 
	CALL 	INST 
	GOTO 	MHZ 
;----------------------------------- 
	END

Now she can concentrate on her job

Only changes i made in the config location are
1. _CP _ALL is changed as _CP _OFF and
2. ADDED errorlevel -302
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
Thanks Sarma..:)

EDIT:

Hi Dawn,
You say you dont know where the code came from..?
The code seems to work OK.

Looking thru it, I would suggest you hit the delete button, its dreadful.:eek:
 
Last edited:

Dawny

Member
Hey thanks all. With the new code the counter seems to work well enough... using a simple 2MHz Crystal driven Colpitts oscillator (I hope that is the correct name) the counter shows 1.9999917 MHz, does that seem close enough?

Well Thanks all again.

Dawn
 

Pommie

Well-Known Member
Most Helpful Member
Eric, while I wouldn't use the word elegant, it does work. I must say though, it took me a while to work out what it was doing and where to put that return. The read of the LCD status is particularly confusing.

To be fair, I suspect that it was written for a 12 bit core and so the only way to code it was in line. For anyone not aware of the fact, 12 bit cores had a stack that contained only 2 words.

Maybe we should start a competition. See who can produce the most elegant translation.

Mike.
 

Pommie

Well-Known Member
Most Helpful Member
I'll start with the MIRROR routine,:D :D

Old,
Code:
MIRROR:                  
                CLRF    TEMP2   
                MOVWF   TEMP1   
                BTFSC   TEMP1,0 
                BSF     TEMP2,7 
                BTFSC   TEMP1,1 
                BSF     TEMP2,6 
                BTFSC   TEMP1,2 
                BSF     TEMP2,5 
                BTFSC   TEMP1,3 
                BSF     TEMP2,4 
                BTFSC   TEMP1,4 
                BSF     TEMP2,3 
                BTFSC   TEMP1,5 
                BSF     TEMP2,2 
                BTFSC   TEMP1,6 
                BSF     TEMP2,1 
                BTFSC   TEMP1,7 
                BSF     TEMP2,0 
                MOVF    TEMP2,W 
                RETURN

New,
Code:
Mirror		movwf	Temp
		clrf	Answer
		bsf	Answer,0
MirrorLoop	rrf	Temp,F
		rlf	Answer,F
		btfss	STATUS,C
		goto	MirrorLoop
		movfw	Answer
		return

Mike.
 

ericgibbs

Well-Known Member
Most Helpful Member
Pommie said:
Eric, while I wouldn't use the word elegant, it does work. I must say though, it took me a while to work out what it was doing and where to put that return. The read of the LCD status is particularly confusing.

To be fair, I suspect that it was written for a 12 bit core and so the only way to code it was in line. For anyone not aware of the fact, 12 bit cores had a stack that contained only 2 words.

Maybe we should start a competition. See who can produce the most elegant translation.

Mike.

hi Mike,
It was mainly the LCD coding part that was IMO 'confused'.
As you say. most likely a 'hand me down' from an earlier device.

Shouldn't you be in bed at this time.. :rolleyes:

Regards
 

kongo127

New Member
Hello all!

This is my first post, although i´ve been watching this forum as a guest for some time.

I´m an electronics technician, but don´t have many experience (yet) with assembly language.

I found this forum from google, while searching for PIC / LCD info.

----

I do have the same problem regarding a frequency meter i´ve built, some digits appear on the second line, just like described here from Dawny.

I´m using a 16x2 LCD display. The project was designed for an 16x1, but also says that they´re interchangable.

I cannot get the 16x1 LCD, but did managed a 20x1 one to see what differences would i get from it.

I was expecting to get only the first complete line, or something similar, but it still does not work properly (even worst than the 16x2 one).

I´ve made a small video and uploaded to youtube in case that someone could give me a little help please.
VIDEO HERE: https://nl.youtube.com/watch?v=InvmeLZUf_0


The 16x2 lcd display behaves like this for 9Mhz input signal:

Freq.:
9,000,000,00


And like this for frequencies higher than 10Mhz (one more digit):

Freq.: 1
000,000,00


Any ideas/clues how to solve this issue please?


Many thanks for your precious time! :)

Miguel
 
Last edited:

kongo127

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

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

            GOTO    Label_0001
            ORG     0x0004
            GOTO    Label_0002
Label_002C  ADDWF   PCL       , f
            RETLW   0x08
            RETLW   0x00
            RETLW   0x98
            RETLW   0x96
            RETLW   0x80
            RETLW   0x86
            RETLW   0x86
            RETLW   0x07
            RETLW   0x00
            RETLW   0x0F
            RETLW   0x42
            RETLW   0x40
            RETLW   0x87
            RETLW   0x87
            RETLW   0x06
            RETLW   0x00
            RETLW   0x01
            RETLW   0x86
            RETLW   0xA0
            RETLW   0xC0
            RETLW   0xC0
            RETLW   0x05
            RETLW   0x00
            RETLW   0x00
            RETLW   0x27
            RETLW   0x10
            RETLW   0xC2
            RETLW   0xC1
            RETLW   0x04
            RETLW   0x00
            RETLW   0x00
            RETLW   0x03
            RETLW   0xE8
            RETLW   0xC3
            RETLW   0xC3
            RETLW   0x03
            RETLW   0x00
            RETLW   0x00
            RETLW   0x00
            RETLW   0x64
            RETLW   0xC4
            RETLW   0xC4
            RETLW   0x02
            RETLW   0x00
            RETLW   0x00
            RETLW   0x00
            RETLW   0x0A
            RETLW   0xC6
            RETLW   0xC5
            RETLW   0x01
            RETLW   0x00
            RETLW   0x00
            RETLW   0x00
            RETLW   0x01
            RETLW   0xC7
            RETLW   0xC7
            RETLW   0xFF
Label_0030  ADDWF   PCL       , f
            RETLW   0x01
            RETLW   0x56
            RETLW   0x46
            RETLW   0x4F
            RETLW   0x2B
            RETLW   0x49
            RETLW   0x46
            RETLW   0x02
            RETLW   0x49
            RETLW   0x46
            RETLW   0x2D
            RETLW   0x56
            RETLW   0x46
            RETLW   0x4F
            RETLW   0x03
            RETLW   0x56
            RETLW   0x46
            RETLW   0x4F
            RETLW   0x2D
            RETLW   0x49
            RETLW   0x46
            RETLW   0xFF
Label_0002  RETFIE
Label_0001  CLRF    PORTA
            CLRF    PORTB
            BSF     STATUS    , RP0
            MOVLW   0xFF
            MOVWF   TRISA
            MOVLW   0x00
            MOVWF   TRISB
            MOVLW   0x27
            MOVWF   OPTION_REG
            BCF     STATUS    , RP0
            CALL    Label_0003
            CALL    Label_0004
            CALL    Label_0005
Label_0009  CLRF    TMR0
            CLRF    0x37
            BCF     INTCON    , T0IF
            BSF     STATUS    , RP0
            MOVLW   0xFF
            MOVWF   TRISA
            BCF     STATUS    , RP0
            CALL    Label_0004
            BCF     PORTA     , 03
            BSF     STATUS    , RP0
            MOVLW   0xF7
            MOVWF   TRISA
            BCF     STATUS    , RP0
            CALL    Label_0006
            CALL    Label_0007
            BTFSS   PORTA     , 00
            GOTO    Label_0008
            CALL    Label_0004
            GOTO    Label_0009
Label_0008  CALL    Label_0004
            BTFSS   PORTA     , 00
            GOTO    Label_0008
            MOVLW   0x07
            MOVWF   0x3B
            CALL    Label_000A
Label_0011  CALL    Label_000B
            CALL    Label_000C
Label_000F  BTFSS   PORTA     , 00
            GOTO    Label_000D
            BTFSS   PORTA     , 01
            GOTO    Label_000E
            GOTO    Label_000F
Label_000E  CALL    Label_0004
            BTFSS   PORTA     , 01
            GOTO    Label_000E
            CALL    Label_0010
            GOTO    Label_0011
Label_000D  CALL    Label_0004
            BTFSS   PORTA     , 00
            GOTO    Label_000D
            DECFSZ  0x3B      , f
            GOTO    Label_0011
            CALL    Label_0012
Label_0018  CALL    Label_0013
Label_0016  BTFSS   PORTA     , 00
            GOTO    Label_0014
            BTFSS   PORTA     , 01
            GOTO    Label_0015
            GOTO    Label_0016
Label_0015  CALL    Label_0004
            BTFSS   PORTA     , 01
            GOTO    Label_0015
            DECFSZ  0x30      , f
            GOTO    Label_0017
            MOVLW   0x03
            MOVWF   0x30
Label_0017  GOTO    Label_0018
Label_0014  CALL    Label_0004
            BTFSS   PORTA     , 00
            GOTO    Label_0014
            CALL    Label_0019
            GOTO    Label_0009
Label_0006  MOVF    TMR0      , W
            MOVWF   0x38
            BTFSS   INTCON    , T0IF
            GOTO    Label_001A
            INCF    0x37      , f
            BCF     INTCON    , T0IF
Label_001A  CLRF    0x3A
            DECF    0x3A      , f
Label_001D  BCF     PORTA     , 03
            BSF     PORTA     , 03
            MOVF    TMR0      , W
            SUBWF   0x38      , W
            BTFSC   STATUS    , Z
            GOTO    Label_001B
            GOTO    Label_001C
Label_001B  INCF    0x3A      , f
            GOTO    Label_001D
Label_001C  COMF    0x3A      , W
            MOVWF   0x39
            RETURN
Label_0007  MOVF    0x30      , W
            DECFSZ  0x30      , f
            GOTO    Label_001E
            MOVWF   0x30
            CLRF    0x0E
            MOVF    0x37      , W
            MOVWF   0x0F
            MOVF    0x38      , W
            MOVWF   0x10
            MOVF    0x39      , W
            MOVWF   0x11
            MOVLW   0x0E
            MOVWF   0x32
            MOVLW   0x2C
            MOVWF   0x31
            CALL    Label_001F
            GOTO    Label_0020
Label_001E  DECFSZ  0x30      , f
            GOTO    Label_0021
            MOVWF   0x30
            CLRF    0x12
            MOVF    0x37      , W
            MOVWF   0x13
            MOVF    0x38      , W
            MOVWF   0x14
            MOVF    0x39      , W
            MOVWF   0x15
            MOVLW   0x2C
            MOVWF   0x31
            MOVLW   0x0E
            MOVWF   0x32
            MOVLW   0x04
            MOVWF   0x0D
            CALL    Label_0022
            MOVLW   0x0E
            MOVWF   0x32
            MOVLW   0x12
            MOVWF   0x31
            CALL    Label_0023
            DECFSZ  0x16      , W
            GOTO    Label_0020
            CLRF    0x0E
            CLRF    0x0F
            CLRF    0x10
            CLRF    0x11
            GOTO    Label_0020
Label_0021  MOVWF   0x30
            CLRF    0x0E
            MOVF    0x37      , W
            MOVWF   0x0F
            MOVF    0x38      , W
            MOVWF   0x10
            MOVF    0x39      , W
            MOVWF   0x11
            MOVLW   0x0E
            MOVWF   0x32
            MOVLW   0x2C
            MOVWF   0x31
            CALL    Label_0023
            DECFSZ  0x16      , W
            GOTO    Label_0020
            CLRF    0x0E
            CLRF    0x0F
            CLRF    0x10
            CLRF    0x11
Label_0020  MOVLW   0x0E
            MOVWF   0x31
            MOVLW   0x28
            MOVWF   0x32
            MOVLW   0x04
            MOVWF   0x0D
            CALL    Label_0022
            CALL    Label_0024
            CLRF    0x3E
            CALL    Label_0025
            CALL    Label_0026
            CALL    Label_0027
            RETURN
Label_000B  MOVLW   0x2C
            MOVWF   0x31
            MOVLW   0x28
            MOVWF   0x32
            MOVLW   0x04
            MOVWF   0x0D
            CALL    Label_0022
            CALL    Label_0024
            MOVLW   0x01
            MOVWF   0x3E
            CALL    Label_0025
            CALL    Label_0028
            CALL    Label_0027
            RETURN
Label_0013  CALL    Label_0029
            CALL    Label_002A
            CALL    Label_0027
            RETURN
Label_0010  MOVLW   0x2C
            MOVWF   0x31
            MOVLW   0x28
            MOVWF   0x32
            MOVLW   0x04
            MOVWF   0x0D
            CALL    Label_0022
            CALL    Label_0024
            MOVF    0x3B      , W
            SUBLW   0x08
            ADDLW   0x20
            MOVWF   FSR
            INCF    INDF      , f
            MOVLW   0x0A
            SUBWF   INDF      , W
            BTFSC   STATUS    , Z
            CLRF    INDF
            CALL    Label_002B
            MOVLW   0x2C
            MOVWF   0x32
            MOVLW   0x28
            MOVWF   0x31
            MOVLW   0x04
            MOVWF   0x0D
            CALL    Label_0022
            RETURN
Label_003D  CLRW
Label_002F  MOVWF   0x34
            CALL    Label_002C
            MOVWF   0x36
            MOVLW   0xFF
            SUBWF   0x36      , W
            BTFSC   STATUS    , Z
            GOTO    Label_002D
            MOVF    0x36      , W
            SUBWF   0x33      , W
            BTFSC   STATUS    , Z
            GOTO    Label_002E
            MOVF    0x34      , W
            ADDLW   0x07
            GOTO    Label_002F
Label_002E  MOVF    0x34      , W
            ADDLW   0x01
            CALL    Label_002C
            MOVWF   0x12
            MOVF    0x34      , W
            ADDLW   0x02
            CALL    Label_002C
            MOVWF   0x13
            MOVF    0x34      , W
            ADDLW   0x03
            CALL    Label_002C
            MOVWF   0x14
            MOVF    0x34      , W
            ADDLW   0x04
            CALL    Label_002C
            MOVWF   0x15
            MOVF    0x34      , W
            ADDLW   0x05
            BTFSS   PORTA     , 02
            ADDLW   0x01
            CALL    Label_002C
            MOVWF   0x16
Label_002D  RETURN
Label_0029  CLRW
Label_0033  MOVWF   0x34
            CALL    Label_0030
            MOVWF   0x36
            MOVLW   0xFF
            SUBWF   0x36      , W
            BTFSC   STATUS    , Z
            GOTO    Label_0031
            MOVF    0x36      , W
            SUBWF   0x30      , W
            BTFSC   STATUS    , Z
            GOTO    Label_0032
            MOVF    0x34      , W
            ADDLW   0x07
            GOTO    Label_0033
Label_0032  MOVF    0x34      , W
            ADDLW   0x01
            CALL    Label_0030
            MOVWF   0x22
            MOVF    0x34      , W
            ADDLW   0x02
            CALL    Label_0030
            MOVWF   0x23
            MOVF    0x34      , W
            ADDLW   0x03
            CALL    Label_0030
            MOVWF   0x24
            MOVF    0x34      , W
            ADDLW   0x04
            CALL    Label_0030
            MOVWF   0x25
            MOVF    0x34      , W
            ADDLW   0x05
            CALL    Label_0030
            MOVWF   0x26
            MOVF    0x34      , W
            ADDLW   0x06
            CALL    Label_0030
            MOVWF   0x27
Label_0031  RETURN
Label_001F  CLRF    0x16
            MOVLW   0x04
            MOVWF   0x0D
            MOVLW   0x03
            ADDWF   0x31      , f
            MOVLW   0x03
            ADDWF   0x32      , f
Label_0037  MOVF    0x32      , W
            MOVWF   FSR
            MOVF    0x16      , W
            ADDWF   INDF      , f
            CLRF    0x16
            BTFSS   STATUS    , C
            GOTO    Label_0034
            MOVLW   0x01
            MOVWF   0x16
Label_0034  MOVF    0x31      , W
            MOVWF   FSR
            MOVF    INDF      , W
            MOVWF   0x34
            MOVF    0x32      , W
            MOVWF   FSR
            MOVF    0x34      , W
            ADDWF   INDF      , f
            BTFSS   STATUS    , C
            GOTO    Label_0035
            MOVLW   0x01
            MOVWF   0x16
Label_0035  DECFSZ  0x0D      , f
            GOTO    Label_0036
            RETURN
Label_0036  DECF    0x31      , f
            DECF    0x32      , f
            GOTO    Label_0037
Label_0023  CLRF    0x16
            MOVLW   0x04
            MOVWF   0x0D
            MOVLW   0x03
            ADDWF   0x31      , f
            MOVLW   0x03
            ADDWF   0x32      , f
Label_003B  MOVF    0x32      , W
            MOVWF   FSR
            MOVF    0x16      , W
            SUBWF   INDF      , f
            CLRF    0x16
            BTFSC   STATUS    , C
            GOTO    Label_0038
            MOVLW   0x01
            MOVWF   0x16
Label_0038  MOVF    0x31      , W
            MOVWF   FSR
            MOVF    INDF      , W
            MOVWF   0x34
            MOVF    0x32      , W
            MOVWF   FSR
            MOVF    0x34      , W
            SUBWF   INDF      , f
            BTFSC   STATUS    , C
            GOTO    Label_0039
            MOVLW   0x01
            MOVWF   0x16
Label_0039  DECFSZ  0x0D      , f
            GOTO    Label_003A
            RETURN
Label_003A  DECF    0x31      , f
            DECF    0x32      , f
            GOTO    Label_003B
Label_003E  CLRF    0x17
Label_003C  CALL    Label_0023
            INCF    0x17      , f
            DECFSZ  0x16      , W
            GOTO    Label_003C
            CALL    Label_001F
            DECF    0x17      , f
            RETURN
Label_0022  MOVF    0x31      , W
            MOVWF   FSR
            MOVF    INDF      , W
            MOVWF   0x34
            MOVF    0x32      , W
            MOVWF   FSR
            MOVF    0x34      , W
            MOVWF   INDF
            INCF    0x31      , f
            INCF    0x32      , f
            DECFSZ  0x0D      , f
            GOTO    Label_0022
            RETURN
Label_0024  MOVF    0x28      , W
            MOVWF   0x0E
            MOVF    0x29      , W
            MOVWF   0x0F
            MOVF    0x2A      , W
            MOVWF   0x10
            MOVF    0x2B      , W
            MOVWF   0x11
            MOVLW   0x08
            MOVWF   0x33
            MOVLW   0x20
            MOVWF   FSR
            MOVLW   0x0E
            MOVWF   0x32
            MOVLW   0x12
            MOVWF   0x31
Label_003F  MOVF    FSR       , W
            MOVWF   0x35
            CALL    Label_003D
            CALL    Label_003E
            MOVF    0x35      , W
            MOVWF   FSR
            MOVF    0x17      , W
            MOVWF   INDF
            INCF    FSR       , f
            DECFSZ  0x33      , f
            GOTO    Label_003F
            RETURN
Label_0025  BTFSS   PORTA     , 02
            GOTO    Label_0040
            MOVLW   0x20
            MOVWF   0x31
            MOVLW   0x1E
            MOVWF   0x32
            MOVLW   0x03
            MOVWF   0x0D
            CALL    Label_0022
            MOVLW   0x23
            MOVWF   0x31
            MOVLW   0x22
            MOVWF   0x32
            MOVLW   0x03
            MOVWF   0x0D
            GOTO    Label_0041
Label_0040  MOVLW   0x20
            MOVWF   0x31
            MOVLW   0x1E
            MOVWF   0x32
            MOVLW   0x04
            MOVWF   0x0D
            CALL    Label_0022
            MOVLW   0x24
            MOVWF   0x31
            MOVLW   0x23
            MOVWF   0x32
            MOVLW   0x03
            MOVWF   0x0D
Label_0041  CALL    Label_0022
            CALL    Label_0042
            RETURN
Label_0042  MOVLW   0x0A
            MOVWF   0x0D
            MOVLW   0x1E
            MOVWF   FSR
Label_004A  MOVLW   0x07
            BTFSS   PORTA     , 02
            MOVLW   0x06
            SUBWF   0x0D      , W
            BTFSC   STATUS    , Z
            GOTO    Label_0043
            MOVLW   0x03
            BTFSS   PORTA     , 02
            MOVLW   0x02
            SUBWF   0x0D      , W
            BTFSS   STATUS    , Z
            GOTO    Label_0044
Label_0043  MOVLW   0x20
            MOVF    0x3E      , f
            BTFSS   STATUS    , Z
            MOVLW   0x2E
            GOTO    Label_0045
Label_0044  MOVF    INDF      , W
            BTFSC   STATUS    , Z
            GOTO    Label_0046
            GOTO    Label_0047
Label_0046  MOVF    0x3E      , f
            BTFSS   STATUS    , Z
            GOTO    Label_0048
            ADDLW   0x20
            GOTO    Label_0045
Label_0048  ADDLW   0x30
            GOTO    Label_0045
Label_0047  INCF    0x3E      , f
            ADDLW   0x30
Label_0045  MOVWF   INDF
            DECFSZ  0x0D      , f
            GOTO    Label_0049
            RETURN
 

kongo127

New Member
The board didn´t allow me to post the entire code in just one post, so i had to brake it in two parts.

This is the remaining:


Code:
Label_0049  INCF    FSR       , f
            GOTO    Label_004A
Label_002B  CLRF    0x28
            CLRF    0x29
            CLRF    0x2A
            CLRF    0x2B
            MOVLW   0x08
            MOVWF   0x33
            MOVLW   0x20
            MOVWF   FSR
            MOVLW   0x28
            MOVWF   0x32
            MOVLW   0x12
            MOVWF   0x31
Label_004D  MOVF    FSR       , W
            MOVWF   0x35
            CALL    Label_003D
            MOVF    0x35      , W
            MOVWF   FSR
            MOVF    INDF      , W
            MOVWF   0x3C
Label_004C  MOVF    0x3C      , f
            BTFSC   STATUS    , Z
            GOTO    Label_004B
            CALL    Label_001F
            DECF    0x3C      , f
            GOTO    Label_004C
Label_004B  MOVF    0x35      , W
            MOVWF   FSR
            INCF    FSR       , f
            DECFSZ  0x33      , f
            GOTO    Label_004D
            RETURN
Label_0026  MOVLW   0x46
            MOVWF   0x18
            MOVLW   0x72
            MOVWF   0x19
            MOVLW   0x65
            MOVWF   0x1A
            MOVLW   0x71
            MOVWF   0x1B
            MOVLW   0x2E
            MOVWF   0x1C
            MOVLW   0x3A
            MOVWF   0x1D
            RETURN
Label_0028  MOVLW   0x49
            MOVWF   0x18
            MOVLW   0x46
            MOVWF   0x19
            MOVLW   0x73
            MOVWF   0x1A
            MOVLW   0x65
            MOVWF   0x1B
            MOVLW   0x74
            MOVWF   0x1C
            MOVLW   0x3A
            MOVWF   0x1D
            RETURN
Label_002A  MOVLW   0x4D
            MOVWF   0x18
            MOVLW   0x6F
            MOVWF   0x19
            MOVLW   0x64
            MOVWF   0x1A
            MOVLW   0x65
            MOVWF   0x1B
            MOVLW   0x20
            MOVWF   0x1C
            MOVLW   0x73
            MOVWF   0x1D
            MOVLW   0x65
            MOVWF   0x1E
            MOVLW   0x74
            MOVWF   0x1F
            MOVLW   0x3A
            MOVWF   0x20
            MOVLW   0x20
            MOVWF   0x21
            RETURN
Label_0005  MOVLW   0x23
            MOVWF   PORTB
            BCF     PORTB     , 05
            CALL    Label_0004
            MOVLW   0x23
            MOVWF   PORTB
            BCF     PORTB     , 05
            CALL    Label_0004
            MOVLW   0x23
            MOVWF   PORTB
            BCF     PORTB     , 05
            CALL    Label_0004
            MOVLW   0x22
            MOVWF   PORTB
            BCF     PORTB     , 05
            CALL    Label_0004
            MOVLW   0x28
            MOVWF   0x0C
            CALL    Label_004E
            CALL    Label_0004
            MOVLW   0x06
            MOVWF   0x0C
            CALL    Label_004E
            CALL    Label_0004
            MOVLW   0x0C
            MOVWF   0x0C
            CALL    Label_004E
            CALL    Label_0004
            MOVLW   0x01
            MOVWF   0x0C
            CALL    Label_004E
            CALL    Label_0004
            RETURN
Label_0027  MOVLW   0x80
            MOVWF   0x0C
            CALL    Label_004E
            MOVLW   0x08
            MOVWF   0x0D
            MOVLW   0x18
            MOVWF   FSR
Label_0050  MOVF    INDF      , W
            MOVWF   0x0C
            CALL    Label_004F
            INCF    FSR       , f
            DECFSZ  0x0D      , f
            GOTO    Label_0050
            MOVLW   0xC0
            MOVWF   0x0C
            CALL    Label_004E
            MOVLW   0x08
            MOVWF   0x0D
Label_0051  MOVF    INDF      , W
            MOVWF   0x0C
            CALL    Label_004F
            INCF    FSR       , f
            DECFSZ  0x0D      , f
            GOTO    Label_0051
            RETURN
Label_000A  MOVLW   0x0D
            MOVWF   0x0C
            CALL    Label_004E
            CALL    Label_0004
            RETURN
Label_0012  MOVLW   0x0C
            MOVWF   0x0C
            CALL    Label_004E
            CALL    Label_0004
            RETURN
Label_000C  MOVF    0x3B      , W
            MOVWF   0x33
            CALL    Label_003D
            MOVF    0x16      , W
            MOVWF   0x0C
            CALL    Label_004E
            RETURN
Label_004E  SWAPF   0x0C      , W
            ANDLW   0x0F
            IORLW   0x20
            MOVWF   PORTB
            BCF     PORTB     , 05
            CALL    Label_0052
            MOVF    0x0C      , W
            ANDLW   0x0F
            IORLW   0x20
            MOVWF   PORTB
            BCF     PORTB     , 05
            CALL    Label_0052
            RETURN
Label_004F  SWAPF   0x0C      , W
            ANDLW   0x0F
            IORLW   0x30
            MOVWF   PORTB
            BCF     PORTB     , 05
            CALL    Label_0052
            MOVF    0x0C      , W
            ANDLW   0x0F
            IORLW   0x30
            MOVWF   PORTB
            BCF     PORTB     , 05
            CALL    Label_0052
            RETURN
Label_0003  MOVLW   0x05
            MOVWF   0x0D
            CLRF    EEADR
            MOVLW   0x2C
            MOVWF   FSR
Label_0053  BSF     STATUS    , RP0
            BSF     EECON1    , 00
            BCF     STATUS    , RP0
            MOVF    EEDATA    , W
            MOVWF   INDF
            INCF    EEADR     , f
            INCF    FSR       , f
            DECFSZ  0x0D      , f
            GOTO    Label_0053
            RETURN
Label_0019  MOVLW   0x05
            MOVWF   0x0D
            CLRF    EEADR
            MOVLW   0x2C
            MOVWF   FSR
            BSF     STATUS    , RP0
            BSF     EECON1    , 02
            BCF     STATUS    , RP0
Label_0055  MOVF    INDF      , W
            MOVWF   EEDATA
            BSF     STATUS    , RP0
            MOVLW   0x55
            MOVWF   EECON2
            MOVLW   0xAA
            MOVWF   EECON2
            BSF     EECON1    , 01
Label_0054  BTFSS   EECON1    , 04
            GOTO    Label_0054
            BCF     EECON1    , 04
            BCF     STATUS    , RP0
            INCF    EEADR     , f
            INCF    FSR       , f
            DECFSZ  0x0D      , f
            GOTO    Label_0055
            BCF     STATUS    , RP0
            RETURN
Label_005B  MOVLW   0xC5
            MOVWF   0x3A
Label_0057  GOTO    Label_0056
Label_0056  DECFSZ  0x3A      , f
            GOTO    Label_0057
            BTFSS   INTCON    , T0IF
            GOTO    Label_0058
            INCF    0x37      , f
            BCF     INTCON    , T0IF
            GOTO    Label_0059
Label_0058  NOP
            GOTO    Label_0059
Label_0059  NOP
            GOTO    Label_005A
Label_005A  RETURN
Label_005D  CALL    Label_005B
            CALL    Label_005B
            CALL    Label_005B
            CALL    Label_005B
            CALL    Label_005B
            CALL    Label_005B
            CALL    Label_005B
            CALL    Label_005B
            CALL    Label_005B
            CALL    Label_005B
            GOTO    Label_005C
Label_005C  RETURN
Label_0004  MOVLW   0x0A
            MOVWF   0x3D
Label_005E  CALL    Label_005D
            DECFSZ  0x3D      , f
            GOTO    Label_005E
            GOTO    Label_005F
Label_005F  RETURN
Label_0052  MOVLW   0x14
            MOVWF   0x3D
Label_0060  NOP
            NOP
            DECFSZ  0x3D      , f
            GOTO    Label_0060
            RETURN
 
            ORG     0x2000
            DATA    0x0F
            DATA    0x0F
            DATA    0x0F
            DATA    0x0F
 
            ORG     0x2007
            DATA    0x19
 
            ORG     0x2100
            DATA    0x00
            DATA    0x00
            DATA    0x00
            DATA    0x00
            DATA    0x01

            END



Cheers in advance,

Miguel
 
Last edited:

leedude

New Member
i should probably point something out here: (i dont think anyone has said it)
most 16x1 displays are controlled like a 8x2.

A 16x2 display:
[--------------Line 1(16)-------------]
[--------------Line 2(16)-------------]


A 16x1 display:
[----Line 1(8)----][----Line 2(8)----]


so if you put chars into the first line, only 8 of them will appear.
to access the other 8 chars of the display, you need to write chars to the second line.
Im not sure why these displays are not just 1 line of 16 chars.

EDIT: going back, i see that it has in fact been said.:(
 
Last edited:

kongo127

New Member
Oh my God!

The world is so small!!!

I´ve posted here to get some help, regarding a 50Mhz Frequency Meter project that i´ve found on an Italian RadioAmateur webpage.

I´m having problems to display the caracters correctly on the LCD.

So i started going back, and getting the source code, so that i can learn how it all works.

I´ve sent an email to him, but without reply.

Now i see that the real project father is this forum´s moderator! :eek:

I found out, when i did a search on google for Nigel Goodwin, and pointed to this same place.


My best respect for you Mr. Nigel Goodwin!



Best Regards from Portugal!

Miguel
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Now i see that the real project father is this forum´s moderator! :eek:

I found out, when i did a search on google for Nigel Goodwin, and pointed to this same place.

Sorry, nothing to do with me, the code you posted has been created by an old version of my PIC disassembler, which is why it has my name at the top.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Top