Example LCD in mikrobasic pro PIC 18f8520

General discussion on mikroC.
Post Reply
Author
Message
jrat
Posts: 1
Joined: 15 Jan 2012 22:00

Example LCD in mikrobasic pro PIC 18f8520

#1 Post by jrat » 15 Jan 2012 22:14

Hi!, i have a problem when i try to run the example of the LCD in my bigpic5 (use pic 18f8520). It doesnt appear anything in my lcd and i dont know why!!. However, when i build other examples its everything right, but with the lcd examples is not working. What can i do?
This is the example that comes with the Mikrobasic pro for pic:

program Lcd_Test

' Lcd module connections
dim LCD_RS as sbit at RD2_bit
dim LCD_EN as sbit at RD3_bit
dim LCD_D4 as sbit at RD4_bit
dim LCD_D5 as sbit at RD5_bit
dim LCD_D6 as sbit at RD6_bit
dim LCD_D7 as sbit at RD7_bit

dim LCD_RS_Direction as sbit at TRISD2_bit
dim LCD_EN_Direction as sbit at TRISD3_bit
dim LCD_D4_Direction as sbit at TRISD4_bit
dim LCD_D5_Direction as sbit at TRISD5_bit
dim LCD_D6_Direction as sbit at TRISD6_bit
dim LCD_D7_Direction as sbit at TRISD7_bit
' End Lcd module connections

dim txt1 as char[16]
txt2 as char[9]
txt3 as char[8]
txt4 as char[7]
i as byte ' Loop variable

sub procedure Move_Delay() ' Function used for text moving
Delay_ms(500) ' You can change the moving speed here
end sub

main:
txt1 = "mikroElektronika"
txt2 = "BigPIC5"
txt3 = "Lcd4bit"
txt4 = "example"

CMCON = CMCON or 0x07 ' turn off comparators
ADCON1 = ADCON1 or 0x0F ' turn off analog inputs

Lcd_Init() ' Initialize Lcd
Lcd_Cmd(_LCD_CLEAR) ' Clear display
Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off

Lcd_Out(1,6,txt3) ' Write text in first row
Lcd_Out(2,6,txt4) ' Write text in second row
Delay_ms(2000)
Lcd_Cmd(_LCD_CLEAR) ' Clear display

Lcd_Out(1,1,txt1) ' Write text in first row
Lcd_Out(2,5,txt2) ' Write text in second row
Delay_ms(500)

' Moving text
for i = 0 to 4 ' Move text to the right 4 times
Lcd_Cmd(_LCD_SHIFT_RIGHT)
Move_Delay()
next i

while TRUE ' Endless loop
for i = 0 to 8 ' Move text to the left 7 times
Lcd_Cmd(_LCD_SHIFT_LEFT)
Move_Delay()
next i

for i = 0 to 8 ' Move text to the right 7 times
Lcd_Cmd(_LCD_SHIFT_RIGHT)
Move_Delay()
next i
wend
end.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Example LCD in mikrobasic pro PIC 18f8520

#2 Post by filip » 19 Jan 2012 16:23

Hi,

Please, try the Lcd example from the attachment and inform me of the results.
Be sure to set the contrast using P1 potentiometer and turn on the LCD backlight on SW1.8.

Regards,
Filip.
Attachments
Lcd.rar
(2.85 KiB) Downloaded 393 times

Post Reply

Return to “mikroC General”