|
|
View previous topic :: View next topic |
Author |
Message |
trirath Guest
|
cannot show LCD on line 2 |
Posted: Sat Oct 24, 2009 1:07 am |
|
|
Hi
I just transfer from MikroC to CCS.
I am wonder it may simple for you but I can not do.
I have 2 problem need help.
1) I can not write string on LCD second line.(2X16) it show only first line.
2) Need to reset many times to start program (Observe from something appear or disappear on LCD).
And after turn on power to PIC sometime work sometime not work (need to reset many time).
Please some help me. Simple code below.
Code: |
#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
#use rs232(baud=38400, xmit=PIN_C6, rcv=PIN_C7)
#include <lcd.c>
#include <string.h>
#include <input.c>
void main(){
int32 str1 = 11115;
int32 str2 = 21115;
int32 str3 = 31115 ;
int32 str4 = 41115 ;
Lcd_Init(); // Initialize LCD I use PortD
lcd_putc('\f');
printf(lcd_putc,"%lu",str1); //Display result
lcd_gotoxy(10,1);
printf(lcd_putc,"%lu",str2); //Display result
lcd_gotoxy(1,2);
printf(lcd_putc,"%lu",str3); //Display result
lcd_gotoxy(10,2);
printf(lcd_putc,"%lu",str4); //Display result
while(TRUE){
}
} |
|
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Sat Oct 24, 2009 7:31 am |
|
|
Try displaying something simple first. Use this code:
Code: | printf(lcd_putc, "\f"); \\clears the screen
printf(lcd_putc,"Hey!"); \\first line
printf(lcd_putc,"\n"); \\new line
printf(lcd_putc,"Test line 2"); |
Regarding your need to reset, put a small delay after lcd_init(). Maybe
Quote: | And after turn on power to PIC sometime work sometime not work | Try to isolate the cause of this problem. Is it due to the LCD itself? Or is it caused by the PIC. Write a simple program to blink an LED. If it works fine, then your LCD (or the interface to the LCD) is what is causing the problem. If the LED blinking does not work, then you need to concentrate your troubleshooting to the PIC.
The reset problem could also be due to a noisy power supply, missing resistor on MCLR, watchdog timer (though from the code you posted, it doesn't seem so), maybe even the LCD backlight sucking a whole lot of power (try adding a series resistor to the LCD backlight LED if this is the case).
Your reset problem is very vaguely posted. I won't be able to help you without further details. Try the solutions above and post your results.
Rohit |
|
|
trirath Guest
|
|
Posted: Sun Oct 25, 2009 10:34 pm |
|
|
I put some little delay that you advised. Anything cleared
but need to be delay_ms(100) for my LCD.
Thank |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|