chirag2239
Member level 3
- Joined
- Jul 29, 2011
- Messages
- 64
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,288
- Activity points
- 2,048
Hello All,
I have a following program written for PIC16F84a.
I need it to be done for PIC16LF1847. The pin structure of both the PIC are same. I am simulating the attached schematic in Proteus and I have decomposed the device PIC16F84a and changed the name of the device only with keeping all the parameters and details as it is in Proteus and I have make device as PIC16LF1847.
Now the following code is for PIC16F84a. When I am trying to compile and build it i Proteus, I get error.
So can anyone help me to solve this error and can let me know the changes that can be done for PIC16LF1847 in this program?
When I changed the library #include p16f84a.inc to
#include p16lf1847.inc, it gives erroe that undefined RP0 in Initialize port in following program.
So can anyone provide the compiled program? or can suggest the changes that need to be done in this program to make this program for PIC16LF1847?
One more time I will let you know that the difference in PIC16F84A and PIC16LF1847 is only the difference of name. So in the attached schematic, the schematic will be as it is or will be the same for PIC16LF1847.
The Program :
I have a following program written for PIC16F84a.
I need it to be done for PIC16LF1847. The pin structure of both the PIC are same. I am simulating the attached schematic in Proteus and I have decomposed the device PIC16F84a and changed the name of the device only with keeping all the parameters and details as it is in Proteus and I have make device as PIC16LF1847.
Now the following code is for PIC16F84a. When I am trying to compile and build it i Proteus, I get error.
So can anyone help me to solve this error and can let me know the changes that can be done for PIC16LF1847 in this program?
When I changed the library #include p16f84a.inc to
#include p16lf1847.inc, it gives erroe that undefined RP0 in Initialize port in following program.
So can anyone provide the compiled program? or can suggest the changes that need to be done in this program to make this program for PIC16LF1847?
One more time I will let you know that the difference in PIC16F84A and PIC16LF1847 is only the difference of name. So in the attached schematic, the schematic will be as it is or will be the same for PIC16LF1847.
The Program :
Code:
#include p16f84a.inc
;**************** Label Definition ********************
ORG 0x00
#DEFINE E PORTA,0
#DEFINE RS PORTA,1
#DEFINE START PORTA,2
#DEFINE STOP PORTA,3
#DEFINE RESET PORTA,4
D1 EQU 0X12
D2 EQU 0X13
D3 EQU 0X14
COUNT1 EQU 0X15
COUNT2 EQU 0X16
;----------Initialize-------------------------------------
;MAIN PROGRAM START HERE
;---------------------------------------------------------
BEGIN
CLRF PORTA
CLRF PORTB
;----------Initiliaze Port--------------------------------
BSF STATUS,RP0
CLRF TRISB
MOVLW 0X1C
MOVWF TRISA
BCF STATUS,RP0
MOVLW 0X01
MOVWF 0X0D
MOVWF 0X0E
MOVWF 0X30
MOVWF 0X31
MOVWF 0X32
;----------Initialize LCD----------------------------------
CALL FUNCSET
CALL DIS_ON
CALL DELAY_5MS ; delay to LCD rise the voltage
CLRF 0X0F
CALL ADDRS_START
;------------START_text------------------------------------
MOVF 0F,W ;insert thw count to wreg
CALL TEXT ;call text STOP
BSF RS ;Command register enable
MOVWF PORTB ;Display text
CALL Enable ;enable the LCD
INCF 0F,W ;Increase count, place yo the wreg
XORLW D'8' ;Check wheather the count egual = 8
BTFSC 03,02 ;check the zero flag in status register
GOTO TIME ;if all the text show, jump to next command
INCF 0F,F ;increase count
GOTO $-0A ;if count no equal, loop to display the text
;-------------SHOW_00:00:00.0------------------------------
TIME
CALL ADDRS_TIME
CLRF 0X0F
MOVF 0F,W
CALL TIMER
BSF RS
MOVWF PORTB
CALL Enable
INCF 0F,W
XORLW D'10'
BTFSC 03,02
GOTO SWITCH
INCF 0F,F
GOTO $-0A
;-------------Switch---------------------------------------
SWITCH
BTFSC START ; check the Start button pressed
GOTO $-1 ; if not pressed, repeat, else will skip this step
;---------XX:XX:XX.0---------------------------------------
MMSEC1
CALL ADDRS_START
CLRF 0X0F
MOVF 0F,W
CALL RUN
BSF RS
MOVWF PORTB
CALL Enable
INCF 0F,W
XORLW D'8'
BTFSC 03,02
GOTO MMSEC
INCF 0F,F
GOTO $-0A+
;---------XX:XX:X0.x----------------------------------------
MMSEC
CALL ADDRS_MMSEC
ULE
BTFSS STOP ;is it STOP button pressed?
GOTO FINISH ;if pressed, jump to stop location
MOVF 0D,W ;if not press, proceed the instruction
CALL NO
BSF RS
MOVWF PORTB ;display at LCD
CALL Enable
CALL DELAY_0.1S ; delay 0.1 seconds
CALL MOVE_LEFT ;move location display
INCF 0D,W ;INCREASE
XORLW D'10' ;would that make it increase to 9?
BTFSC 03,02 ;set the zero flag in status register
GOTO MSEC
INCF 0D,F
BTFSS STOP ;is it STOP button pressed?
GOTO FINISH ;if pressed, jump to stop location
GOTO ULE ;if not pressed, proceed counter
;-------XX:XX:0X.X-----------------
MSEC
CALL ADDRS_MSEC
MOVF 0E,W
CALL NO
BSF RS
MOVWF PORTB
CALL Enable
CALL ADDRS_MMSEC
CLRF 0D
MOVF 0D,W
CALL NO
BSF RS
MOVWF PORTB
CALL Enable
CALL DELAY_0.1S
INCF 0D,F
INCF 0E,W
XORLW D'11'
BTFSC 03,02
GOTO SEC
INCF 0E,F
GOTO MMSEC
;--------XX:X0:XX.X---------------
SEC
CALL ADDRS_SEC
MOVF 30,W
CALL NO
BSF RS
MOVWF PORTB
CALL Enable
CALL ADDRS_MSEC
CLRF 0E
MOVF 0E,W
CALL NO
BSF RS
MOVWF PORTB
CALL Enable
INCF 0E,F
INCF 0D,F
INCF 30,W
XORLW D'7'
BTFSC 03,02
GOTO NEXT_SEC
INCF 30,F
GOTO MMSEC
;-------XX:X0:XX.X-----
NEXT_SEC
CALL ADDRS_NEXTSEC
MOVF 31,W
CALL NO
BSF RS
MOVWF PORTB
CALL Enable
CALL ADDRS_SEC
CLRF 30
MOVF 30,W
CALL NO
BSF RS
MOVWF PORTB
CALL Enable
INCF 30,F
CLRF 0E
MOVF 0E,W
CALL NO
BSF RS
MOVWF PORTB
CALL Enable
INCF 0E,F
INCF 0D,F
INCF 31,W
XORLW D'11'
BTFSC 03,02
GOTO FINISH
INCF 31,F
GOTO MMSEC
;---TIME STOP-----------
FINISH
CALL ADDRS_START
CLRF 0X0F
MOVF 0F,W
CALL TEXT_STOP1
BSF RS
MOVWF PORTB
CALL Enable
INCF 0F,W
XORLW D'8'
BTFSC 03,02
GOTO $+03
INCF 0F,F
GOTO $-0A
BTFSS RESET ; check the reset button
GOTO BEGIN ; if press goto initliaze program
BTFSS START ; check the start button
GOTO MMSEC1 ; if pressed, continue counter
GOTO $-04 ; loop to check both button
;--------SUBROUTINE TO DISPLAY------------
Enable
BSF E
BCF E
CALL DELAY_125MCS
RETLW 0
NO
ADDWF PCL
RETLW '0'
RETLW '1'
RETLW '2'
RETLW '3'
RETLW '4'
RETLW '5'
RETLW '6'
RETLW '7'
RETLW '8'
RETLW '9'
TEXT
ADDWF PCL
RETLW 'S'
RETLW 'T'
RETLW 'A'
RETLW 'R'
RETLW 'T'
RETLW 0X20 ;BLANK SPACE
RETLW 0X20 ;BLANK SPACE
RETLW 0X20 ;BLANK SPACE
RUN
ADDWF PCL
RETLW 'R'
RETLW 'U'
RETLW 'N'
RETLW 'N'
RETLW 'I'
RETLW 'N'
RETLW 'G'
RETLW '!'
TIMER
ADDWF PCL
RETLW '0'
RETLW '0'
RETLW ':'
RETLW '0'
RETLW '0'
RETLW ':'
RETLW '0'
RETLW '0'
RETLW '.'
RETLW '0'
TEXT_STOP1
ADDWF PCL
RETLW 'S'
RETLW 'T'
RETLW 'O'
RETLW 'P'
RETLW '!'
RETLW '!'
RETLW 0X20
RETLW 0X20
;--------COMMAND FOR LCD-----------
FUNCSET
BCF RS
CALL DELAY_125MCS
MOVLW 0x38 ; code for 8 bit LCD and 2 lines
MOVWF PORTB
CALL Enable
RETURN
DIS_ON
BCF RS
CALL DELAY_125MCS
MOVLW 0x0C ; code for display On and off cursor
MOVWF PORTB
CALL Enable
RETURN
ENTRY_MODE
BCF RS
CALL DELAY_125MCS
MOVLW 0x06
MOVWF PORTB
CALL Enable
RETURN
MOVE_LEFT
BCF RS
CALL DELAY_125MCS
MOVLW 0x10
MOVWF PORTB
CALL Enable
RETURN
;------address display----------------------------
ADDRS_MSEC
BCF RS
CALL DELAY_125MCS
MOVLW 0xC8
MOVWF PORTB
CALL Enable
RETURN
ADDRS_SEC
BCF RS
CALL DELAY_125MCS
MOVLW 0xC7
MOVWF PORTB
CALL Enable
RETURN
ADDRS_NEXTSEC
BCF RS
CALL DELAY_125MCS
MOVLW 0xC5
MOVWF PORTB
CALL Enable
RETURN
ADDRS_MMSEC
BCF RS
CALL DELAY_125MCS
MOVLW 0xCA
MOVWF PORTB
CALL Enable
RETURN
ADDRS_START
BCF RS
CALL DELAY_125MCS
MOVLW 0x85
MOVWF PORTB
CALL Enable
RETURN
ADDRS_TIME
BCF RS
CALL DELAY_125MCS
MOVLW 0xC1
MOVWF PORTB
CALL Enable
RETURN
;------Delay subroutine------
DELAY_125MCS
MOVLW D'42'
MOVWF D3
DECFSZ D3,F
GOTO $-1
RETURN
DELAY_5MS
MOVLW D'41'
MOVWF D2
CALL DELAY_125MCS
DECFSZ D2,F
GOTO $-2
RETURN
DELAY_0.1S
MOVLW D'50'
MOVWF D3
MOVLW D'13'
MOVWF D2
MOVLW D'50'
MOVWF D1
DECFSZ D1
GOTO $-1
DECFSZ D2
GOTO $-5
DECFSZ D3
GOTO $-9
RETURN
END
Attachments
Last edited by a moderator: