sirdizel
Newbie level 3
- Joined
- May 17, 2013
- Messages
- 4
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,310
I am using a PIC16C57 in order to control a 16x1 LCD. When I run my program I am unable to produce anything at the LCD and I can't seem to find the problem. I tried stopping the progam at the clear display and also when the crusor is on and still there is nothing showing on the LCD. Here is my code I was just wondering If anyone could point me in the right direction of where im going wrong. Many Thanks.
Code:
list p=16C57
org 0x00
Call Setup; Sets up the ports and timer
Call Int; Calls for the Initialzation sub rountine
Call Enable; latchs the value
Call IntTime; alows for the time delay to take place indorder for the routine to be carried out
Call Int;
Call Enable;
Call IntTime;
Call Int;
Call Enable;
Call IntTime;
Call FunSet; Calls the function set code
Call Enable;
Call IntTime;
Call Disoff; Calls the display off code
Call Enable;
Call IntTime;
Call Dison; Calls the display on code
Call Enable;
Call IntTime;
Call Disclr; Calls the display clear code
Call Enable;
Call IntTime;
Call Ent; calls the entry mode code
Call Enable;
Call IntTime;
Call DDRAM1; calls the DDRAM1 code to give the position of the display
Call Enable;
Call IntTime;
Call A; calls the ASCII code to display the letter A
Call Enable;
Call IntTime;
Stop: goto Stop;
Setup: movlw 0x00; moves the value 0 to the w reg to set port up as output
tris 0x05; sets port a as output
movlw 0x00;
tris 0x06; sets port b as output
movlw 0xff; moves the value ff to w reg to set port as input
tris 0x07; sets port c as input
movlw 0x04; sends the value 04 to the w reg
option; sets up timmer
return; returns the program to main routine
Int: bcf 0x05,0; Clears bit 0 port a
bcf 0x05,1; clears bit 1 port a
bcf 0x05,2; clears bit 2 port a
movlw 0x30; moves 30 to w reg
movwf 0x06; moves the value 30 to port b
return;
Enable: bsf 0x05,2; sets bit 2 at port a to a logic 1
bcf 0x05,2; sets bit 2 port a to a logic 0
return;
IntTime: movlw 0x05; moves the value 5 to w reg
movwf 0x0a; moves 5 to file 0a
again: clrf 0x01; clears timer
loop: movlw 0x7d; moves the value 7d to w reg
subwf 0x01,0; subtract 1 away from the value 7d
btfss 0x03,2; bit test the status reg and skips if set
goto loop; goes to loop
decfsz 0x0a,1; takes one away from file 0a and skips next instruction if its 0
goto again; goes to again
return;
FunSet: bcf 0x05,0; Sets the RS to 0
bcf 0x05,1; Sets the R/W to 0
movlw 0x34; moves the hexadecimal value 34 (00110100) makes it 8 bits,1 line and 5x10 dot characters used
movwf 0x06; sends the value 34 to port b
return;
Disoff: bcf 0x05,0;
bcf 0x05,1;
movlw 0x08;moves the hexadecimal value 08 (00001000) makes display off, cursor off and blinking off
movwf 0x06;moves the value 08 to port b
return;
Dison: bcf 0x05,0;
bcf 0x05,1;
movlw 0x0e; moves the hexadecimal value 0e (00001110) makes the diaplay on, cursor on and blinking off
movwf 0x06;
return;
Disclr: bcf 0x05,0;
bcf 0x05,1;
movlw 0x01; move the hexadecimal value 01(00000001) calls for the display to be cleared
movwf 0x06;
return;
Ent: bcf 0x05,0;
bcf 0x05,1;
movlw 0x06; moves the hexadecimal value 06 (00000110) makes crusor position increment(left to right) and display remains still while cursor moves
movwf 0x06;
return;
DDRAM1: bcf 0x05,0;
bcf 0x05,1;
movlw 0x07; moves thr hexadecimal value 07 making the display postion in the middle
movwf 0x06;
return;
A: bsf 0x05,0; Sets the RS to 1 to select the data register and send information to the LCD
bcf 0x05,1;
movlw 0x41; moves the hexadecimal value 41 (01000001) ASCII value for the letter A
movwf 0x06;
return;
org 0x1FF;
goto 0x00;
end;