I cant seem to fix it
like the numbers displayed or what not goes dim and some are fine but some arent
Code:
list p=16f877 #include <p16f877A.inc>
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF
#define LCD_RS PORTE,0 ;Define the pin for the LCD RS Control Line
#define LCD_RW PORTE,1 ;Define the pin for the LCD R/W Control Line
#define LCD_E PORTE,2 ;Define the pin for the LCD E Control Line
#define LCD_DATA PORTD ;Define the pins for LCD Data Lines
COUNTER1 EQU 0x020 ;Memory address for Counter 1
COUNTER2 EQU 0x021 ;Memory address for Counter 2
COUNTER3 EQU 0x022 ;MEMORY ADDRESS FOR COUNTER 3
ORG 0x0000
RESET_V goto START ;Reset Vector
ORG 0x0005
START clrf PORTD ;Clear PORTD Output Latches.
clrf PORTE ;Clear PORTE Output Latches.
bsf STATUS,RP0 ;Switch to Bank 1.
movlw 0x07 ;Load W with 0x07
movwf ADCON1 ;Copy W into ADCON1 (Switch Port A and E into Digital Mode)
clrf TRISD ;Switch all Port D pins to output mode
clrf TRISE ;Switch all Port E pins to output mode
bcf STATUS,RP0 ;Switch to Bank 0
; call LOCKED_MODE
; call HOLD_LOCKED
; call UNLOCKED_MODE
; call HOLD_UNLOCKED
; call IDLE_MODE
; call HOLD_IDLE
; call STEP_MODE
; call HOLD_STEP
; call POS_MODE
; call HOLD_POS
LOCKED_MODE bcf LCD_RW ;Clear LCD_RW line to write data to the LCD
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'00111000' ;Load the function set command into working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00001110' ;Load the Display On command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000110' ;Load the Entry Mode Set command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000001' ;Load the Clear Screen command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
Call LONG_DELAY ;Call the Long Delay Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw 'S' ;Load the first letter of your First Name into the Working Register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'Y' ;Write the remaining letters of your First Name to the screen
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'S'
Call LCD_WRITE
movlw 'T'
Call LCD_WRITE
movlw 'E'
Call LCD_WRITE
movlw 'M'
Call LCD_WRITE
movlw '_'
Call LCD_WRITE
movlw 'L'
Call LCD_WRITE
movlw 'O'
Call LCD_WRITE
movlw 'C'
Call LCD_WRITE
movlw 'K'
Call LCD_WRITE
movlw 'E'
Call LCD_WRITE
movlw 'D'
Call LCD_WRITE
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'11000000' ;Load the command into the working register that places the cursor on the second line of the LCD
Call LCD_WRITE ;Call the LCD_Write Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw '1' ;Load the first letter of your Surname into the Working Register
Call LCD_WRITE
movlw '1'
Call LCD_WRITE
movlw '4'
Call LCD_WRITE
movlw '6'
Call LCD_WRITE
movlw '3'
Call LCD_WRITE
movlw '3'
Call LCD_WRITE
movlw '3'
Call LCD_WRITE
movlw '2'
Call LCD_WRITE
; return
HOLD_LOCKED btfsc PORTB, 5
goto HOLD_LOCKED
UNLOCKED_MODE bcf LCD_RW ;Clear LCD_RW line to write data to the LCD
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'00111000' ;Load the function set command into working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00001110' ;Load the Display On command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000110' ;Load the Entry Mode Set command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000001' ;Load the Clear Screen command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
Call LONG_DELAY ;Call the Long Delay Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw 'S' ;Load the first letter of your First Name into the Working Register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'Y' ;Write the remaining letters of your First Name to the screen
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'S'
Call LCD_WRITE
movlw 'T'
Call LCD_WRITE
movlw 'E'
Call LCD_WRITE
movlw 'M'
Call LCD_WRITE
movlw '_'
Call LCD_WRITE
movlw 'U'
Call LCD_WRITE
movlw 'N'
Call LCD_WRITE
movlw 'L'
Call LCD_WRITE
movlw 'O'
Call LCD_WRITE
movlw 'C'
Call LCD_WRITE
movlw 'K'
Call LCD_WRITE
movlw 'E'
Call LCD_WRITE
movlw 'D'
Call LCD_WRITE
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'11000000' ;Load the command into the working register that places the cursor on the second line of the LCD
Call LCD_WRITE ;Call the LCD_Write Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw '1' ;Load the first letter of your Surname into the Working Register
Call LCD_WRITE
movlw '1'
Call LCD_WRITE
movlw '4'
Call LCD_WRITE
movlw '6'
Call LCD_WRITE
movlw '3'
Call LCD_WRITE
movlw '3'
Call LCD_WRITE
movlw '3'
Call LCD_WRITE
movlw '2'
Call LCD_WRITE
; return
HOLD_UNLOCKED btfsc PORTB, 4
goto HOLD_UNLOCKED
IDLE_MODE bcf LCD_RW ;Clear LCD_RW line to write data to the LCD
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'00111000' ;Load the function set command into working register
call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00001110' ;Load the Display On command into the working register
call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000110' ;Load the Entry Mode Set command into the working register
call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000001' ;Load the Clear Screen command into the working register
call LCD_WRITE ;Call the LCD_Write Subroutine
call LONG_DELAY ;Call the Long Delay Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw 'I' ;Load the first letter of your First Name into the Working Register
call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'D' ;Write the remaining letters of your First Name to the screen
call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'L'
call LCD_WRITE
movlw 'E'
call LCD_WRITE
movlw '_'
call LCD_WRITE
movlw 'M'
call LCD_WRITE
movlw 'O'
call LCD_WRITE
movlw 'D'
call LCD_WRITE
movlw 'E'
call LCD_WRITE
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'11000000' ;Load the command into the working register that places the cursor on the second line of the LCD
call LCD_WRITE ;Call the LCD_Write Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw 'S' ;Load the first letter of your Surname into the Working Register
call LCD_WRITE
movlw 'Y'
call LCD_WRITE
movlw 'S'
call LCD_WRITE
movlw 'T'
call LCD_WRITE
movlw 'E'
call LCD_WRITE
movlw 'M'
call LCD_WRITE
movlw '_'
call LCD_WRITE
movlw 'E'
call LCD_WRITE
movlw 'N'
call LCD_WRITE
movlw 'A'
call LCD_WRITE
movlw 'B'
call LCD_WRITE
movlw 'L'
call LCD_WRITE
movlw 'E'
call LCD_WRITE
movlw 'D'
call LCD_WRITE
; return
HOLD_IDLE btfsc PORTB, 2
goto HOLD_IDLE
STEP_MODE bcf LCD_RW ;Clear LCD_RW line to write data to the LCD
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'00111000' ;Load the function set command into working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00001110' ;Load the Display On command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000110' ;Load the Entry Mode Set command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000001' ;Load the Clear Screen command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
Call LONG_DELAY ;Call the Long Delay Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw 'S' ;Load the first letter of your First Name into the Working Register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'T' ;Write the remaining letters of your First Name to the screen
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'E'
Call LCD_WRITE
movlw 'P'
Call LCD_WRITE
movlw '_'
Call LCD_WRITE
movlw 'M'
Call LCD_WRITE
movlw 'O'
Call LCD_WRITE
movlw 'D'
Call LCD_WRITE
movlw 'E'
Call LCD_WRITE
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'11000000' ;Load the command into the working register that places the cursor on the second line of the LCD
Call LCD_WRITE ;Call the LCD_Write Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw 'S' ;Load the first letter of your Surname into the Working Register
Call LCD_WRITE
movlw 'T'
Call LCD_WRITE
movlw 'E'
Call LCD_WRITE
movlw 'P'
Call LCD_WRITE
movlw 'S'
Call LCD_WRITE
movlw ':'
Call LCD_WRITE
movlw 'X'
Call LCD_WRITE
movlw 'X'
Call LCD_WRITE
movlw 'Y'
Call LCD_WRITE
movlw 'Y'
Call LCD_WRITE
movlw 'Y'
Call LCD_WRITE
; return
HOLD_STEP btfsc PORTB,2
goto STEP_MODE
POS_MODE bcf LCD_RW ;Clear LCD_RW line to write data to the LCD
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'00111000' ;Load the function set command into working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00001110' ;Load the Display On command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000110' ;Load the Entry Mode Set command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw B'00000001' ;Load the Clear Screen command into the working register
Call LCD_WRITE ;Call the LCD_Write Subroutine
Call LONG_DELAY ;Call the Long Delay Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw 'P' ;Load the first letter of your First Name into the Working Register
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'O' ;Write the remaining letters of your First Name to the screen
Call LCD_WRITE ;Call the LCD_Write Subroutine
movlw 'S'
Call LCD_WRITE
movlw 'I'
Call LCD_WRITE
movlw 'O'
Call LCD_WRITE
movlw 'N'
Call LCD_WRITE
movlw '_'
Call LCD_WRITE
movlw 'M'
Call LCD_WRITE
movlw 'O'
Call LCD_WRITE
movlw 'D'
Call LCD_WRITE
movlw 'E'
Call LCD_WRITE
bcf LCD_RS ;Clear LCD_RS line to write control commands
movlw B'11000000' ;Load the command into the working register that places the cursor on the second line of the LCD
Call LCD_WRITE ;Call the LCD_Write Subroutine
bsf LCD_RS ;Set the LCD_RS control line to write characters to the display
movlw 'X' ;Load the first letter of your Surname into the Working Register
Call LCD_WRITE
movlw 'X'
Call LCD_WRITE
movlw 'X'
Call LCD_WRITE
movlw ':'
Call LCD_WRITE
movlw 'Y'
Call LCD_WRITE
movlw 'Y'
Call LCD_WRITE
movlw 'Y'
Call LCD_WRITE
movlw ':'
Call LCD_WRITE
movlw 'Z'
Call LCD_WRITE
movlw 'Z'
Call LCD_WRITE
movlw 'Z'
Call LCD_WRITE
movlw ':'
Call LCD_WRITE
movlw 'D'
Call LCD_WRITE
movlw 'D'
Call LCD_WRITE
movlw 'D'
Call LCD_WRITE
; return
HOLD_POS btfsc PORTB,2
goto HOLD_POS
goto IDLE_MODE
;********************************************************************************************************
; Subroutine Section
;********************************************************************************************************
; LCD Write - loads a command into the LCD Controller
;********************************************************************************************************
LCD_WRITE bsf LCD_E ;Set the LCD Enable Pin
movwf LCD_DATA ;Write the command in the working register to the LCD Data Lines
nop ;No Operation
nop ;No Operation
bcf LCD_E ;Clear the LCD Enable Pin
call SHORT_DELAY ;Call the Short_Delay subroutine to Wait the minimum instruction execution time
return ;Return to where the routine was called from
;********************************************************************************************************
; Short Delay (approx 60us)
;********************************************************************************************************
SHORT_DELAY movlw D'100' ;Load 100 into the Working register
movwf COUNTER1 ;Copy the Working register into the Counter1 register
C1_DEC
decfsz COUNTER1,F ;Decrement the Counter 1 register
goto C1_DEC ;Goto C1_DEC
return ;Return to where the routine was called from
;********************************************************************************************************
; Long Delay (approx 6ms)
;********************************************************************************************************
LONG_DELAY movlw D'100' ;Load 100 into the Working register
movwf COUNTER2 ;Copy the Working register into the Counter2 register
DLY_C2_DEC
call SHORT_DELAY ;Call the SHORT_DELAY subroutine
decfsz COUNTER2,F ;Decrement the Counter 2 register
goto DLY_C2_DEC ;Goto DLY_C2_DEC
return ;Return to where the routine was called from
END
Thats the Code if someone can help me please
Bookmarks