Continue to Site

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.

pic16f88 lcd doesnt work On Port A?

Status
Not open for further replies.

tracidfish

New Member
Hi
I have used this code to operate my LCD on a pic16f628 and a pic 18.

i now wish to use a pic16f88. I can get this code to work on portB but i cannot get it to work on port A. I realy need this to work on port a as i wish to use the tx and rx on port b for another function.

when I apply power to the pic I get the black squares, then the dissapear.

can any one see where i may be going wrong?

The LCD is connected to the correct pic pins.
I understand that i do not need pull ups on port a (like i did on one of the pins on the 16f628) as all pins (other than 5) have full cmos output, is this correct?


i am setting my config bits from mplab
oscilator = INTRC-osc2 as RA6
WDT = off
PUT = on
MCLRE = RA5
BODEN = On
LVP=Disabled
CPD = Off
CCP1mux = RB0
CP=Off
FCMEN=disabled
IESO=Disabled


Thank you
Charlie

Code:
	LIST	p=16F88		;tell assembler what chip we are using
	include "P16F88.inc"		;include the defaults for the chip



		cblock	0x20			;start of general purpose registers
			count			;used in looping routines
			count1			;used in delay routine
			counta			;used in delay routine
			countb			;used in delay routine
			tmp1			;temporary storage
			tmp2
			tmp3
			templcd			;temp store for 4 bit mode
			templcd2
			offsetL			;table registers
			offsetH
			offsetL1		
			offsetH1
			seconds
			minutes
			hours						
				
		endc

LCD_PORT	Equ	PORTA
LCD_TRIS	Equ	TRISA
LCD_RS		Equ	0x04			;LCD handshake lines
LCD_RW		Equ	0x06
LCD_E		Equ	0x07



;***************************************************************************
;System definition
;***************************************************************************



#define Switch1 PORTB,1
#define Switch2 PORTB,2
#define Switch3 PORTB,0


#define TRISSwitch1     TRISB,1
#define TRISSwitch2     TRISB,2
#define TRISSwitch3     TRISB,0

#define RS232TestData   0x6d

		org	0x0000

INIT
	BSF		STATUS, RP0
	MOVLW	0X72
	MOVWF	OSCCON
	MOVLW	0X07
	MOVWF	CMCON
	CLRF	ANSEL
	movlw	0X7F
	movwf	ADCON1
	MOVLW	0X00
	MOVWF	TRISA 
	MOVWF	TRISB
	BCF	STATUS, RP0
 


Initialise	clrf	count
		clrf	PORTA
		clrf	PORTB


		call	Delay100		;wait for LCD to settle
		call	Delay100		;wait for LCD to settle
		call	Delay100		;wait for LCD to settle
		call	Delay100		;wait for LCD to settle
		call	Delay100		;wait for LCD to settle
	

		call	LCD_Init		;setup LCD



;****************************************************************************
;WELCOM
;****************************************************************************               

	call	LCD_Line1
	movlw	'W'
	call	LCD_Char
	movlw	'E'
	call	LCD_Char
	movlw	'L'
	call	LCD_Char
	movlw	'C'
	call	LCD_Char
	movlw	'O'
	call	LCD_Char
	movlw	'E'
	call	LCD_Char
	movlw	'.'
	call	LCD_Char
	movlw	'T'
	call	LCD_Char
	movlw	'O'
	call	LCD_Char

	call	LCD_Line2
	movlw	'D'
	call	LCD_Char
	movlw	'I'
	call	LCD_Char
	movlw	'V'
	call	LCD_Char
	movlw	'E'
	call	LCD_Char
	movlw	'.'
	call	LCD_Char
	movlw	'B'
	call	LCD_Char
	movlw	'U'
	call	LCD_Char
	movlw	'D'
	call	LCD_Char
	movlw	'Y'
	call	LCD_Char
	movlw	'Y'
	call	LCD_Char
	call	Delay255
	call	Delay255
	call	Delay255
	call	Delay255


Welcome
	call	LCD_Line1
	movlw	'B'
	call	LCD_Char
	movlw	'E'
	call	LCD_Char
	movlw	'S'
	call	LCD_Char
	movlw	'T'
	call	LCD_Char
	movlw	'.'
	call	LCD_Char
	movlw	'M'
	call	LCD_Char
	movlw	'I'
	call	LCD_Char
	movlw	'X'
	call	LCD_Char
	movlw	'M'
	call	LCD_Char
	movlw	'.'
	call	LCD_Char
	movlw	'S'
	call	LCD_Char
	movlw	'W'
	call	LCD_Char
	movlw	'I'
	call	LCD_Char
	movlw	'T'
	call	LCD_Char
	movlw	'C'
	call	LCD_Char
	movlw	'H'
	call	LCD_Char
	movlw	'1'
	call	LCD_Char
	
	call	LCD_Line2
	movlw	'D'
	call	LCD_Char
	movlw	'I'
	call	LCD_Char
	movlw	'V'
	call	LCD_Char
	movlw	'E'
	call	LCD_Char
	movlw	'.'
	call	LCD_Char
	movlw	'T'
	call	LCD_Char
	movlw	'I'
	call	LCD_Char
	movlw	'M'
	call	LCD_Char
	movlw	'E'
	call	LCD_Char
	movlw	'.'
	call	LCD_Char
	movlw	'S'
	call	LCD_Char
	movlw	'W'
	call	LCD_Char
	movlw	'I'
	call	LCD_Char
	movlw	'T'
	call	LCD_Char
	movlw	'C'
	call	LCD_Char
	movlw	'H'
	call	LCD_Char
	movlw	'2'
	call	LCD_Char

goto Welcome


;****************************************************************************
;;Sub routines
;****************************************************************************               


;Initialise LCD
LCD_Init	movlw	0x20			;Set 4 bit mode
		call	LCD_Cmd

		movlw	0x28			;Set display shift
		call	LCD_Cmd

		movlw	0x06			;Set display character mode
		call	LCD_Cmd

		movlw	0x0d			;Set display on/off and cursor command
		call	LCD_Cmd

		call	LCD_Clr			;clear display

		retlw	0x00

; command set routine
LCD_Cmd		movwf	templcd
		swapf	templcd,	w	;send upper nibble
		andlw	0x0f			;clear upper 4 bits of W
		movwf	LCD_PORT
		bcf	LCD_PORT, LCD_RS	;RS line to 0
		call	Pulse_e			;Pulse the E line high

		movf	templcd,	w	;send lower nibble
		andlw	0x0f			;clear upper 4 bits of W
		movwf	LCD_PORT
		bcf	LCD_PORT, LCD_RS	;RS line to 0
		call	Pulse_e			;Pulse the E line high
		call 	Delay5
		retlw	0x00

LCD_CharD	addlw	0x30
LCD_Char	movwf	templcd
		swapf	templcd,	w	;send upper nibble
		andlw	0x0f			;clear upper 4 bits of W
		movwf	LCD_PORT
		bsf	LCD_PORT, LCD_RS	;RS line to 1
		call	Pulse_e			;Pulse the E line high
		movf	templcd,	w	;send lower nibble
		andlw	0x0f			;clear upper 4 bits of W
		movwf	LCD_PORT
		bsf	LCD_PORT, LCD_RS	;RS line to 1
		call	Pulse_e			;Pulse the E line high
		call 	Delay5
		retlw	0x00

LCD_Line1	movlw	0x80			;move to 1st row, first column
		call	LCD_Cmd
		retlw	0x00

LCD_Line2	movlw	0xc0			;move to 2nd row, first column
		call	LCD_Cmd
		retlw	0x00

LCD_Line1W	addlw	0x80			;move to 1st row, column W
		call	LCD_Cmd
		retlw	0x00

LCD_Line2W	addlw	0xc0			;move to 2nd row, column W
		call	LCD_Cmd
		retlw	0x00

LCD_CurOn	movlw	0x0d			;Set display on/off and cursor command
		call	LCD_Cmd
		retlw	0x00

LCD_CurOff	movlw	0x0c			;Set display on/off and cursor command
		call	LCD_Cmd
		retlw	0x00

LCD_Clr		movlw	0x01			;Clear display
		call	LCD_Cmd
		retlw	0x00


Delay255	movlw	0xff		;delay 255 mS
		goto	d0
Delay100	movlw	d'100'		;delay 100mS
		goto	d0
Delay50		movlw	d'50'		;delay 50mS
		goto	d0
Delay20		movlw	d'20'		;delay 20mS
		goto	d0
Delay5		movlw	0x05		;delay 5.000 ms (4 MHz clock)
d0		movwf	count1
d1		movlw	0xC7			;delay 1mS
		movwf	counta
		movlw	0x01
		movwf	countb
Delay_0
		decfsz	counta, f
		goto	$+2
		decfsz	countb, f
		goto	Delay_0

		decfsz	count1	,f
		goto	d1
		retlw	0x00

Pulse_e		bsf	LCD_PORT, LCD_E
		nop
		bcf	LCD_PORT, LCD_E
		retlw	0x00

		end
 
Last edited:
Yes it is connected to 0V.

i can get LEDs to blink, and this exact code works on port B.

I think I have the comparoators on port A set correctly to allow port A to be Digitals.

I have read the data sheet and beleive that i have the oscialaotr set correctly, as 4mHz with no clock out.

Thanks
charlie
 
Yes it is connected to 0V.

i can get LEDs to blink, and this exact code works on port B.

I think I have the comparoators on port A set correctly to allow port A to be Digitals.

I have read the data sheet and beleive that i have the oscialaotr set correctly, as 4mHz with no clock out.

Thanks
charlie

hi Charlie,
I ran in quickly in Oshonsoft and it did display a few characters.

The missing characters indicate that your LCD write delays are too short.
 

Attachments

  • AAesp05.gif
    AAesp05.gif
    6.5 KB · Views: 155
Last edited:
Hi - yes i have connected leds to a0 to a3, i didnt have enough to connect 4-7, but my logic probe shows the pins steeping high then low.

is there any way that i can move the LCD hand shake lines to portB?

LCD_RS Equ 0x04 ;LCD handshake lines
LCD_E Equ 0x07
 
Last edited:
hi Charlie,
I ran in quickly in Oshonsoft and it did display a few characters.

The missing characters indicate that your LCD write delays are too short.

So would that indicate hardware fault?
I havent got any pull up resitors as i do not beleibve i need them?
what config bits did you use in oshonsoft?
 
Hi - yes i have connected leds to a0 to a3, i didnt have enough to connect 4-7, but my logic probe shows the pins steeping high then low.

is there any way that i can move the LCD hand shake lines to portB?

LCD_RS Equ 0x04 ;LCD handshake lines
LCD_E Equ 0x07

Which pins on PORTB do you want to use for the LCD control.?
 
BO and B1 would be fine, this would leave teh uart free and some free for inputs.
Thanks
charlie

hi,
They are now PORT.0 and B.1
This will not solve the delay problems with the LCD.
 

Attachments

  • charlie1.asm
    6.1 KB · Views: 131
hi Charlie,
A simple LCD test program.
LCD data lines [4] on PORTA.low, LCD_RS on PORTB.0 and LCD_ENB on PORTB.1
R/W connected to 0V.
 

Attachments

  • CharlieLCD1.asm
    3.3 KB · Views: 150
Status
Not open for further replies.

Latest threads

Back
Top