Hallo,

Ik ben bezig om een zelf een kabeltester te ontwikkelen met behulp van een PIC. IK gebruik de PIC 16f871. Ik heb op internet een script gevonden om iets op een HD44780 compatible display te zetten. ik heb dit script aan gepast zodat hij op mijn PIC past. Alleen als ik deze met behulp van de Galva-WISP in de PIC laat en het display goed aansluit op de PIC dan krijg ik niks te zien. maar ik heb het script wel getest met PROTEUS en dan werkt het wel goed.

Kunt u mij helpen?

Hierinder staat de asm file:
;**********************************************************************
; This file is a basic code template for object module code
; generation on the PIC16F871. This file contains the
; basic code building blocks to build upon. As a project minimum
; the 16F871.lkr file will also be required for this file to
; correctly build. The .lkr files are located in the MPLAB
; directory.
;
; If interrupts are not used all code presented between the
; code section "INT_VECTOR and code section "MAIN" can be removed.
; In addition the variable assignments for 'w_temp' and
; 'status_temp' can be removed.
;
; If interrupts are used, as in this template file, the 16F871.lkr
; file will need to be modified as follows: Remove the lines
; CODEPAGE NAME=vectors START=0x0 END=0x4 PROTECTED
; and
; SECTION NAME=STARTUP ROM=vectors
; and change the start address of the page0 section from 0x5 to 0x0
;
; Refer to the MPASM User's Guide for additional information on
; features of the assembler and linker (Document DS33014).
;
; Refer to the respective PIC data sheet for additional
; information on the instruction set.
;
;**********************************************************
;
; Filename: xxx.asm
; Date:
; File Version:
;
; Author:
; Company:
;
;
;**********************************************************************
;
; Files required: *
;
;
;
;**********************************************************************
;
; Notes:
;
;
;
;
;**********************************************************

list p=16f871 ; list directive to define processor
#include <p16f871.inc> ; processor specific variable definitions

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC & _WRT_ENABLE_ON & _LVP_ON & _CPD_OFF

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The labels following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.

N EQU 0x20
FIXDELAY EQU 0x21 ; General Purpose Registers.

Start CALL INITPORTS ; Initialize Ports as output/inputs.
CALL INITLCD ; Initialize LCD.

Main CALL TESTMSG ; Print test message on LCD

Forever GOTO $

;---------------------------------------------------------------------------
; Subroutine to initialize the PORTs as Inputs or Outputs.
;---------------------------------------------------------------------------

INITPORTS
BANKSEL PORTC
CLRF PORTE ; Clear PORTs.
CLRF PORTC

BANKSEL TRISC
MOVLW 0x006 ;Configure all pins
MOVWF ADCON1 ;as digital inputs
MOVLW 0x000 ; Define PORTC and PORTE as Outputs.
MOVWF TRISE
MOVWF TRISC

RETURN

;--------------------------------------------------------------------------
; Initialize the LCD.
;-------------------------------------------------------------------------

INITLCD
BANKSEL PORTC ; Select Bank for PORTB.

MOVLW 0xE6 ; Call for 46ms delay
CALL NDELAY ; Wait for VCC of the LCD to reach 5V

BCF PORTE, 0 ; Clear RS to select Instruction Reg.
BCF PORTE, 1 ; Clear R/W to write

MOVLW B'00111011' ; Function Set to 8 bits, 2 lines and 5x7 dot matrix
MOVWF PORTC
CALL ENABLEPULSE
CALL DELAY50
CALL ENABLEPULSE
CALL DELAY50
CALL ENABLEPULSE
CALL DELAY50 ; Call 50us delay and wait for instruction completion

MOVLW B'00001000' ; Display OFF
MOVWF PORTC
CALL ENABLEPULSE
CALL DELAY50 ; Call 50us delay and wait for instruction completion

MOVLW B'00000001' ; Clear Display
MOVWF PORTC
CALL ENABLEPULSE
MOVLW 0x09 ; Call 1.8ms delay and wait for instruction completion
CALL NDELAY

MOVLW B'00000010' ; Cursor Home
MOVWF PORTC
CALL ENABLEPULSE
MOVLW 0x09 ; Call 1.8ms delay and wait for instruction completion
CALL NDELAY

MOVLW B'00001111' ; Display ON, Cursor ON, Blinking ON
MOVWF PORTC
CALL ENABLEPULSE
CALL DELAY50 ; Call 50us delay and wait for instruction completion

MOVLW B'00000110' ; Entry Mode Set, Increment & No display shift
MOVWF PORTC
CALL ENABLEPULSE
CALL DELAY50 ; Call 50us delay and wait for instruction completion

BSF PORTE, 0 ; Set RS to select Data Reg.
BCF PORTE, 1 ; Clear R/W to write
RETURN

;-------------------------------------------------------------------------
; Enable Pulse for writing or reading instructions or data
;-------------------------------------------------------------------------

ENABLEPULSE
BCF PORTE, 2 ; 2us LOW followed by 3us HIGH Enable Pulse and 2us LOW.
NOP
NOP
BSF PORTE, 2
NOP
NOP
NOP
BCF PORTE, 2
NOP
NOP
RETURN

;------------------------------------------------------------------------
; N DELAY SUBROUTINE, delay in multiples of 200us up to 200us*255 = 51ms (or more)
;------------------------------------------------------------------------

NDELAY
MOVWF N ; N is delay multiplier

NOTOVER CALL DELAY200 ; Call for 200us
DECFSZ N, 1 ; Decrease N by 1
GOTO NOTOVER ; The delay isn't done
RETURN

;-------------------------------------------------------------------------
; FIXED 200us DELAY (Possibly more due to execution time of the DECFSZ instruction.)
;-----------------------------------------------------------------------

DELAY200
MOVLW 0x42 ; 66 LOOPS
MOVWF FIXDELAY ; 200us fixed delay

NOTDONE200 DECFSZ FIXDELAY, 1 ; Decrement of FIXDELAY
GOTO NOTDONE200 ; If 200us isn't up go back to NOTDONE200
RETURN ; If 200us is up then return to instruction.

;------------------------------------------------------------------------
; FIXED 50us DELAY (Possibly more due to execution time of the DECFSZ instruction.)
;-----------------------------------------------------------------------

DELAY50
MOVLW 0x10 ; 16 LOOPS
MOVWF FIXDELAY ; 50us fixed delay

NOTDONE50 DECFSZ FIXDELAY, 1 ; Decrement of FIXDELAY
GOTO NOTDONE50 ; If 50us isn't up go back to NOTDONE50
RETURN ; If 50us is up then return to instruction.

;------------------------------------------------------------------------
; FIXED 20us DELAY (Possibly more due to execution time of the DECFSZ instruction.)
;------------------------------------------------------------------------

DELAY20
MOVLW 0x7 ; 7 LOOPS
MOVWF FIXDELAY ; 50us fixed delay

NOTDONE20 DECFSZ FIXDELAY, 1 ; Decrement of FIXDELAY
GOTO NOTDONE20 ; If 50us isn't up go back to NOTDONE50
RETURN ; If 50us is up then return to instruction.

;------------------------------------------------------------------------
; Fast Directive to write characters to LCD.
;----------------------------------------------------------------------

PUTCHAR
MOVWF PORTC ; A quicker way of writing characters to LCD.
CALL ENABLEPULSE
CALL CHKBUSY
RETURN

;------------------------------------------------------------------------
; Subroutine to check for the BUSY flag. Mostly used for instructions that follows up a character write.
;-----------------------------------------------------------------------
CHKBUSY
BCF PORTE, 0 ; Clear RS to select Instruction Reg.
BSF PORTE, 1 ; Set R/W to read.

BANKSEL TRISC ; Select Bank for TRISC.
MOVLW 0xFF ; Define all PORTE Pins as Inputs.
MOVWF TRISC

BANKSEL PORTE ; Select Bank for PORTE.
BSF PORTE, 2 ;
MOVF PORTC, w ;
BCF PORTE, 2 ;
ANDLW 0x80 ; Credits
BTFSS STATUS, Z
GOTO CHKBUSY

BANKSEL TRISC ; Select Bank for TRISB.
MOVLW 0x00 ; Define all PORTE Pins as Outputs.
MOVWF TRISC

BANKSEL PORTE ; Select Bank for PORTA, B, and C.
BSF PORTE, 0 ; Set RS to select Data Register.
BCF PORTE, 1 ; Clear R/W to write.
RETURN

;-----------------------------------------------------------------------
; Position Cursor to the next line.
;-----------------------------------------------------------------------

NEXTLINE
BANKSEL PORTE
BCF PORTE, 0 ; Select Instructions Register.
BCF PORTE, 1 ; Select Write.

MOVLW b'11000000' ; Shift cursor to second line at 0x40 RAM address on LCD.
CALL PUTCHAR
RETURN

;----------------------------------------------------------------------
; Clear screen and Cursor home.
;----------------------------------------------------------------------

CLRSCREEN
BANKSEL PORTE
BCF PORTE, 0 ; Clear RS to select Instructions Register.
BCF PORTE, 1 ; Clear R/W to select Write.

BANKSEL PORTC
MOVLW B'00000001' ; Clear Display
CALL PUTCHAR
RETURN

;-----------------------------------------------------------------------
; Position Cursor to home position.
;----------------------------------------------------------------------

CURSORHOME
BANKSEL PORTC
BCF PORTE, 0 ; Select Instructions Register.
BCF PORTE, 1 ; Select Write.

MOVLW b'00000010' ; Position cursor to home position.
CALL PUTCHAR
RETURN
;----------------------------------------------------------------------
; A test message.
;----------------------------------------------------------------------

TESTMSG MOVLW A'I' ; Displays "I m working fine"
CALL PUTCHAR ; "Line 2 is alrite"
MOVLW A' '
CALL PUTCHAR
MOVLW A'M'
CALL PUTCHAR
MOVLW A' '
CALL PUTCHAR
MOVLW A'W'
CALL PUTCHAR
MOVLW A'O'
CALL PUTCHAR
MOVLW A'R'
CALL PUTCHAR
MOVLW A'K'
CALL PUTCHAR
MOVLW A'I'
CALL PUTCHAR
MOVLW A'N'
CALL PUTCHAR
MOVLW A'G'
CALL PUTCHAR
MOVLW A' '
CALL PUTCHAR
MOVLW A'F'
CALL PUTCHAR
MOVLW A'I'
CALL PUTCHAR
MOVLW A'N'
CALL PUTCHAR
MOVLW A'E'
CALL PUTCHAR

CALL NEXTLINE

MOVLW A'L'
CALL PUTCHAR
MOVLW A'I'
CALL PUTCHAR
MOVLW A'N'
CALL PUTCHAR
MOVLW A'E'
CALL PUTCHAR
MOVLW A' '
CALL PUTCHAR
MOVLW A'2'
CALL PUTCHAR
MOVLW A' '
CALL PUTCHAR
MOVLW A'I'
CALL PUTCHAR
MOVLW A'S'
CALL PUTCHAR
MOVLW A' '
CALL PUTCHAR
MOVLW A'O'
CALL PUTCHAR
MOVLW A'K'
CALL PUTCHAR
MOVLW A'A'
CALL PUTCHAR
MOVLW A'Y'
CALL PUTCHAR
MOVLW A' '
CALL PUTCHAR
MOVLW A' '
CALL PUTCHAR

RETURN

END ; End of program

Heb je gecontroleerd of al je verbindingen naar je schermpje goed lopen en of je contrast goed staat?

Als je scherm power krijgt gaat normaal de bovenste karakters volledig aan(blokjes dus).

hallo,

het display is juist aangesloten, alleen ik krijg geen blokjes op de bovenste lijn te zien, maar dit krijg ik ook niet te zien als ik de LCD op de computer aansluit. en dan werkt het display wel.

groeten Tom

is het een lcd met een serieële interface ipv ene paralelle omdat jij aanhaalt dat je hem op de pc kan zetten.

als het een serieële interface heeft: stuurt hte programma wle serieel uit? en niet parralel(ik heb totaal geen verstand van ASM namelijk)

Hallo,

Het LCD scherm is een PLED LCD dat gebruik maakt van een parallele aansturing.

Groeten,

Tom

In het begin van je progje staat dit:

BCF PORTA, 0 ; Clear RS to select Instruction Reg.
BCF PORTA, 1 ; Clear R/W to write

verderop staat dit:

BCF PORTE, 0 ; Clear RS to select Instruction Reg.
BCF PORTE, 1 ; Clear R/W to write

Zoek het verschil :P

hallo,

bedankt voor de tip, ik heb het veranderd maar helaas werkt het nog steeds niet,

Groeten, Tom

Hallo,

Kan iemand mij misschien helpen?

iks het wel een HD44780 compatible display en kijk even de DS van je display na om te checken of je timing wel goed is.

geen rotte soldeerverbindingen?

als ik de LCD display aansluit op de PC werkt het display wel.

Ik weet 100% zeker dat het een HD 44780 PLED Display is

Probeer de LCD eerst eens met picbasic ofzo aan te spreken, als hij dan werkt kan je de code verder ontleden.