|
|
View previous topic :: View next topic |
Author |
Message |
peaps
Joined: 15 Sep 2008 Posts: 11 Location: Hemel Hempstead, Hertfordshire, UK
|
|
Posted: Mon Sep 15, 2008 3:26 pm |
|
|
Hi,
I would like to mention a potential problem with this library, or maybe I'm doing something wrong..
When I use the \n newline I get a garbage character output to the LCD. I have tried using a 16x2 device and also an 8x2 which did work, but also outputted the same weird character. I have remmed out the #define USE_LCD_RW line and set the pin constants, but apart from that the code is vanilla as taken from the first post.
Does anyone else get this symptom? Using latest compiler on a 16F819.
Thanks,
Andy Peaple.
Code: | #include <16f819.h>
#fuses INTRC_IO, NOWDT, NOPUT, NOMCLR, NOBROWNOUT, NOCPD
#use delay(clock=8000000)
#include <flex_lcd.c>
//==========================
void main()
{
setup_oscillator(OSC_8MHZ);
setup_ccp1(CCP_OFF);
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
delay_ms(2000);
lcd_init(); // Always call this first.
lcd_putc("\fHello World\n");
lcd_putc("Line Number 2");
while(1);
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 15, 2008 3:33 pm |
|
|
1. Post the manufacturer and part number of the 16x2 LCD.
2. Post your compiler version.
3. Post the list of #define statements for the pin connections
between the PIC and the 16x2 LCD.
4. Post the list of physical connections (wires or tracks) between
the LCD and the PIC.
5. Have you connected the R/W pin on the LCD to ground ?
If not, what is it connected to ? |
|
|
peaps
Joined: 15 Sep 2008 Posts: 11 Location: Hemel Hempstead, Hertfordshire, UK
|
|
Posted: Mon Sep 15, 2008 3:58 pm |
|
|
1. Display is made by: Orient Display Co. Ltd., part no. OD-DM1602F.
2. Compiler version: 4.013
3. LCD pin defines:
#define LCD_DB4 PIN_B3
#define LCD_DB5 PIN_B2
#define LCD_DB6 PIN_B1
#define LCD_DB7 PIN_B0
#define LCD_E PIN_A2
#define LCD_RS PIN_A3
#define LCD_RW PIN_A4
4. Pin mappings:
PIN_A2 -=> Enable
PIN_A3 -=> Register Select
PIN_B0 -=> Data_7
PIN_B1 -=> Data_6
PIN_B2 -=> Data_5
PIN_B3 -=> Data_4
PIN_A4 is not connected to anything.
5. The R/W terminal on the LCD module is tied directly to ground.
Thanks
Andy P. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 15, 2008 4:35 pm |
|
|
I don't have vs. 4.013. I have 4.014 and compiled it for that, and
compared the .LST file to vs. 4.079. They're effectively the same.
You don't have the NOLVP fuse but the compiler sets that for you
so that's not the problem. (However, check the end of your .LST
file to confirm this, since you are using a slightly earlier version).
It's possible that there's a problem with the lack of using the R/W pin.
There are several ways to test this.
1. You could remove the GND on the LCD's R/W pin and connect it
to pin A4 on the PIC. Uncomment the USE_RW_PIN line in the
flex driver file. See if it now works when the R/W pin is used.
Or,
2. It's possible that the problem is caused by sensitivity in your LCDs
to the size of the delays in the flex driver. You could increase the
delay in the send_byte() routine from 60 us, to say, 100 us or more.
Also,
You could temporarily reduce the speed of the internal oscillator. Set
your use delay statement to 1 MHz. Change the setup_oscillator()
statement to 1 MHz. You actually don't need this statement. When the
compiler sees the fuse #use delay() statement, it puts in code which
does the same thing as the setup_oscillator() statement. But anyway,
see if the lower oscillator frequency makes it start working. If so, this
is a clue that the delays in the flex driver must be increased for your LCD. |
|
|
peaps
Joined: 15 Sep 2008 Posts: 11 Location: Hemel Hempstead, Hertfordshire, UK
|
|
Posted: Tue Sep 16, 2008 4:02 pm |
|
|
Hi, thanks for the reply.
I have tried connecting the R/W pin to the LCD module, increasing the delay from 60us to 500us and reducing the clock speed of the PIC to 1Mhz, but unfortunately I still get the weird character after a new line.
I have also tried it on a different LCD, a 16x1. I get a different type of character on this module. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
peaps
Joined: 15 Sep 2008 Posts: 11 Location: Hemel Hempstead, Hertfordshire, UK
|
|
Posted: Mon Sep 29, 2008 1:25 pm |
|
|
Just tried the CCS driver lcd.c, but still getting weird char at a \n.
Similar code still...
Code: | #include <16f819.h>
#use delay(clock=1000000)
#include <lcd.c>
#fuses INTRC_IO, NOWDT, NOPUT, NOMCLR, NOBROWNOUT, NOCPD
#bit LED = 5.1
void main(void) {
// set_tris_a(0b00000000);
setup_oscillator(OSC_1MHZ);
setup_ccp1(CCP_OFF);
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
LED = 1;
delay_ms(1000);
LED = 0;
lcd_init();
while(1==1) {
delay_ms(500);
LED = 1;
lcd_putc("\f12345678");
delay_ms(500);
lcd_putc("\f********\n--------");
delay_ms(250);
}
} |
I'll try that other library you mentioned next..
Andy |
|
|
peaps
Joined: 15 Sep 2008 Posts: 11 Location: Hemel Hempstead, Hertfordshire, UK
|
|
Posted: Sat Oct 04, 2008 10:40 am |
|
|
I have found out what the problem is, and frankly, I am surprised that no one else has come across this before. This problem also exists with the CCS lcd.c driver that ships with the compiler.
The strange character is not due to '\n' but rather NULL CHARS at the end of strings.
When calling lcd_putc("Hello World");
a '\0' also gets sent at the end of the string which the LCD just outputs as garbage.
To get around this problem I have made a very small ammendment to the lcd_putc() function:
Quote: | void lcd_putc( char c) {
switch (c) {
case '\f' : lcd_send_byte(0,1);
delay_ms(2);
break;
case '\n' : lcd_gotoxy(1,2); break;
case '\b' : lcd_send_byte(0,0x10); break;
// do nothing in case of Null char
case '\0' : break;
default : lcd_send_byte(1,c); break;
}
} |
Note the additional switch statement that handles null chars.
Andy Peaple |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Oct 04, 2008 12:31 pm |
|
|
Quote: | 2. Compiler version: 4.013 |
Your version is at best, a Beta version of the vs. 4 compiler.
If your version has the bug that you describe, then it should display '00'
at the end of the output, with the test program shown below.
I don't have 4.013 to test, but vs. 4.014 and later, do not put a '00' at
the end. This is the output from a good version of the compiler:
Quote: | 48 65 6C 6C 6F 20 57 6F 72 6C 64 |
Code: |
#include <16F877.H>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay (clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
void lcd_putc(char c)
{
printf("%X ", c);
}
//=================================
void main()
{
lcd_putc("Hello World");
while(1);
} |
|
|
|
DavidW
Joined: 26 Oct 2008 Posts: 1
|
|
Posted: Sun Oct 26, 2008 3:50 pm |
|
|
Hello PCM. I just want to say thanks for this custom LCD.C driver. I been having a tough time figuring out the CCS LCD driver since I am a beginner with PIC programming. I made some modifications to your original code to fit the I/O pins that were available on my PIC but when I compile the code I get an error
Error 128 "flex_lcd.c" Line 28(1,42): A #DEVICE required before this line
and the line with the error is in flex_lcd.c:
int8 const LCD_INIT_STRING[4] =
Do you know why I am getting this error?
I am using a PIC16F877A and a 2x16 HD44780 LCD display. Here are the only modifications I made to flex_lcd.c:
#define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7
#define LCD_E PIN_C1
#define LCD_RS PIN_C2
#define LCD_RW PIN_C3
A little bit more information, I am using version 4.064 for the CCS C compiler. Thanks for your help! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 26, 2008 4:19 pm |
|
|
Quote: | A #DEVICE required before this line |
This type of question belongs in the main forum. If the following
information doesn't fix the problem, then post the question in the
main forum:
Are you using MPLAB ? If so, see these links:
How to use multiple source files with MPLAB:
http://www.ccsinfo.com/forum/viewtopic.php?t=34046
More detailed information on using multiple files with MPLAB.
Read all the links in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=32221 |
|
|
ishmael
Joined: 02 Jun 2009 Posts: 4
|
hello again |
Posted: Tue Jun 02, 2009 3:05 pm |
|
|
my question dissapeared.
can portA be used with this driver for a pic16f648A ? i port B is occupied with USART and 32khz.
Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jun 06, 2009 11:56 am |
|
|
Read the instructions in the first post. Any pin can be used, provided
that it has full i/o capabilities. Don't use input-only pins. If the pin
is open-drain, then an external pull-up resistor must be used on that pin. |
|
|
BotBoy
Joined: 06 Nov 2009 Posts: 6
|
|
Posted: Tue Nov 10, 2009 1:15 pm |
|
|
Code: | lcd_putc("\fHello World\n");
lcd_putc("Line Number 2"); |
Is possible after put these two lines on LCD...
write some word only on line 2 without clean line 1? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 10, 2009 1:46 pm |
|
|
Quote: | Is possible after put these two lines on LCD...
write some word only on line 2 without clean line 1? |
Call the following function in the LCD driver to set the cursor position.
The Origin is (1, 1) and it's in the upper left corner of the LCD.
Quote: | void lcd_gotoxy(int8 x, int8 y) |
You can ask ordinary LCD questions (like this one) in the main forum. |
|
|
|
|
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
|