View previous topic :: View next topic |
Author |
Message |
subi
Joined: 29 Aug 2010 Posts: 24
|
lcd flex driver |
Posted: Sun Aug 29, 2010 2:20 pm |
|
|
Hi everybody!
I have a problem with flex lcd driver with my 20x2 LCD. So I have use the driver for PIC16F887 and everything is OK. But if I used it with PIC18F4321
the LCD works about 5 minutes and after go wrong but the program is running further only LCD is not doing. If I use little frequency (1MH) then the LCD is doing a little more time. So I don't know why. Please help me.
Thank you.
Last edited by subi on Mon Aug 30, 2010 5:18 am; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Aug 29, 2010 4:35 pm |
|
|
What is the oscillator frequency of the 18F4321 on your circuit board ? |
|
|
trirath
Joined: 14 Jun 2010 Posts: 20 Location: Pathunthanee Thailand
|
|
Posted: Mon Aug 30, 2010 1:34 am |
|
|
I also used them with 16F873A (20Mhz). It work fine.
But I changed them run on 18F2550. Nothing display. I set clock 48 Mhz(18F2550).
I still not test in 18F2550 with 20 MHZ due to my LCD die.
Once thing I don't know why since I use flex_lcd. My LCD die 2 set in closely time without reason.
Please give suggestion.
My setting is:
Code: |
#define LCD_DB4 PIN_C0
#define LCD_DB5 PIN_C1
#define LCD_DB6 PIN_C2
#define LCD_DB7 PIN_C4
#define LCD_E PIN_A0
#define LCD_RS PIN_A1
#define LCD_RW PIN_A2
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 31, 2010 3:58 pm |
|
|
I didn't reply for a while because I wasn't sure who replied.
Does "tirath" = "subi" ? But anyway, here is a reply:
Quote: |
#define LCD_DB4 PIN_C0
#define LCD_DB5 PIN_C1
#define LCD_DB6 PIN_C2
#define LCD_DB7 PIN_C4
#define LCD_E PIN_A0
#define LCD_RS PIN_A1
#define LCD_RW PIN_A2 |
Look at the pin descriptions in the 18F2550 data sheet:
Quote: | RC4/D-/VM -- Digital input. |
Pin C4 is an input-only pin. It can't become an output. Therefore it won't
work with the LCD. Choose a different pin (and not pin C5).
The original 16x2 Flex driver was only tested to 20 MHz. It's possible
that you need to modify it to make it work reliably at 48 MHz. If so,
the easiest way is to change all delay_cycles(1) statements to delay_us(1). |
|
|
subi
Joined: 29 Aug 2010 Posts: 24
|
|
Posted: Thu Sep 02, 2010 1:12 am |
|
|
PCM programmer wrote: | What is the oscillator frequency of the 18F4321 on your circuit board ? |
Hi,
Thank you for your question. My oscillator frequency is 4000000 Hz (4MHz). Further information: the pic is not run when the lcd don't show anything. LCD is in the other port the mistake is similar. I think perhaps my pic setup is wrong:
Code: |
#include <18F4321.H>
#device *=16
#device adc=10
#FUSES WDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //XT //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES PUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPB //No Boot Block code protection
#FUSES NOWRTB //Boot block not write protected
#FUSES NOWRTC //configuration not registers write protected
#use delay(clock=4000000,RESTART_WDT)
#byte PORTA = 0xF80 //PORTA regiszterre mutató pointer
#byte LATA = 0xF89 //LATA regiszterre mutató pointer
#byte PORTB = 0xF81 //PORTB regiszterre mutató pointer
#byte LATB = 0xF8A //LATB regiszterre mutató pointer
#byte PORTE = 0xF84 //PORTE regiszterre mutató pointer
#byte LATE = 0xF8D //LATE regiszterre mutató pointer
#byte PORTD = 0xF83 //PORTD regiszterre mutató pointer
#byte LATD = 0xF8C //LATD regiszterre mutató pointer
#byte PORTC = 0xF82 //PORTD regiszterre mutató pointer
#byte LATC = 0xF8B //LATC regiszterre mutató pointer
|
The frequency is not important because to use 1 MHz then pic go wrong too.
Thanks
Subi |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 02, 2010 3:13 pm |
|
|
With a 4 MHz oscillator, there is no problem. I notice you have the
watchdog timer enabled. Why ? You don't need the Watchdog in a
test program. It just adds uncertainty to the troubleshooting. Change
the fuse to NOWDT. |
|
|
subi
Joined: 29 Aug 2010 Posts: 24
|
|
Posted: Fri Sep 03, 2010 2:07 pm |
|
|
PCM programmer wrote: | With a 4 MHz oscillator, there is no problem. I notice you have the
watchdog timer enabled. Why ? You don't need the Watchdog in a
test program. It just adds uncertainty to the troubleshooting. Change
the fuse to NOWDT. |
Hi Programmer,
Thanks your opinion. I have my program without watchdog and my problem is at this moment too. So I dont know what I have done wrong because the program is running without mistake with PIC16f887 and is running a short time with PIC18F4321. So I dont understand this. I would like to ask that the lcd.c program what we find in bettween ccs driver only run without mistake PIC16F87X or PIC16F88X or does this program have to run WITH PIC18FXXX wthout mistake too? Futher I would like to get any ideas about my problem. So please try to help me.
Thanks
Subi |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Sep 03, 2010 2:29 pm |
|
|
Post a list of your #define statements for the Flex lcd driver, that show
the PIC pin assignments for the lcd.
Also post a list of all connections to the LCD (for all lcd pins). |
|
|
languer
Joined: 09 Jan 2004 Posts: 144 Location: USA
|
|
Posted: Fri Sep 03, 2010 11:38 pm |
|
|
Pardon my interjection. I am not a FlexLCD user, but I believe you are saying the following:
- Your program and LCD works on 16Fxxx
- Your program and LCD works on 18Fxxx, but only for a short time; at which point the LCD quits working, but the program remains working
- At 1MHz clock on the 18Fxxx, the LCD works for a little longer (compared with a 4MHz clock)
How do you know the LCD quits working, yet the program still works? The fact that the LCD "works" for a little bit, then quits with the 4MHz clock; and "works" for a little longer with the 1MHz clock seems to point to a code error (i.e. stack issues, reset issues, etc) and not the LCD driver itself.
Again, not a FlexLCD user (yet); but some observations. |
|
|
subi
Joined: 29 Aug 2010 Posts: 24
|
|
Posted: Sat Sep 04, 2010 1:48 am |
|
|
PCM programmer wrote: | Post a list of your #define statements for the Flex lcd driver, that show
the PIC pin assignments for the lcd.
Also post a list of all connections to the LCD (for all lcd pins). |
Hi PCM programmer,
Thanks your answer. I have posted my #define statements for the Flex lcd driver, that show the PIC pin assignments for the lcd.
#define LCD_ENABLE_PIN PIN_B2
#define LCD_RS_PIN PIN_B3
#define LCD_RW_PIN PIN_D7
#define LCD_DATA4 PIN_B4
#define LCD_DATA5 PIN_B5
#define LCD_DATA6 PIN_B6
#define LCD_DATA7 PIN_B7
#include "stdlib.h"
#include "internal_eeprom.c"
#include "lcd.c"
#include "initial.c"
The PORTB 0 has used for INT EXT. PORTB 1 has used for pullup port.
But I read the next writing and I am thinking about it. So perhaps it is possible that my program is not correct. I only don't understand that this code is running with PIC16F887. Why?
I am looking for my program code.
Please you write down your recommendation further too.
Thank you
Subi |
|
|
trirath
Joined: 14 Jun 2010 Posts: 20 Location: Pathunthanee Thailand
|
|
Posted: Sat Sep 04, 2010 5:29 am |
|
|
PCM programmer wrote: | I didn't reply for a while because I wasn't sure who replied.
Does "tirath" = "subi" ? But anyway, here is a reply:
Quote: |
#define LCD_DB4 PIN_C0
#define LCD_DB5 PIN_C1
#define LCD_DB6 PIN_C2
#define LCD_DB7 PIN_C4
#define LCD_E PIN_A0
#define LCD_RS PIN_A1
#define LCD_RW PIN_A2 |
Look at the pin descriptions in the 18F2550 data sheet:
Quote: | RC4/D-/VM -- Digital input. |
Pin C4 is an input-only pin. It can't become an output. Therefore it won't
work with the LCD. Choose a different pin (and not pin C5).
The original 16x2 Flex driver was only tested to 20 MHz. It's possible
that you need to modify it to make it work reliably at 48 MHz. If so,
the easiest way is to change all delay_cycles(1) statements to delay_us(1). |
Hi PCM Programmer
I test them work fine both 16F873A(20Mhz) and 18F2550(48Mhz) no need to modify anything.I am wrong just IO port ,Below is new define.
#define LCD_DB4 PIN_B3
#define LCD_DB5 PIN_B4
#define LCD_DB6 PIN_B5
#define LCD_DB7 PIN_B6
#define LCD_E PIN_C0
#define LCD_RS PIN_C1
#define LCD_RW PIN_A2
However,There something error when I
uncomment #define USE_LCD_RW 1 then connect RW to GND
Printf(LCD_OUT,..) function that is outside while(true) not work properly example as
#include <16F873A.h>
...
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
BYTE CONST TABLE []= {"ADC:"};
void main(void){
...
...
printf(lcd_putc,"%s",TABLE ); <---- NO display since start
//delay_ms(3000); // for test findction above
While(True){
....
lcd_gotoxy(5,1);
printf(lcd_putc,"%1.4w V",result_adc); <--- work fine
...
}}
but it work if
#include <16F873A.h>
...
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
void main(void){
...
...
printf(lcd_putc,"ADC:" ); <--- work fine
While(True){
....
lcd_gotoxy(5,1);
printf(lcd_putc,"%1.4w V",result_adc); <--- work fine
...
}}
Just remind you for a new version flex lcd.
Many Many Thank you |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Sep 04, 2010 12:05 pm |
|
|
Quote: |
#define LCD_ENABLE_PIN PIN_B2
#define LCD_RS_PIN PIN_B3
#define LCD_RW_PIN PIN_D7
#define LCD_DATA4 PIN_B4
#define LCD_DATA5 PIN_B5
#define LCD_DATA6 PIN_B6
#define LCD_DATA7 PIN_B7
|
The pins shown in bold are used by the ICD debugger. If the ICD is plugged into the board, the LCD won't work.
I suggest that you choose two other pins. |
|
|
trirath
Joined: 14 Jun 2010 Posts: 20 Location: Pathunthanee Thailand
|
|
Posted: Sun Sep 05, 2010 1:51 am |
|
|
Hi PCM Programmer
1) I tested them with unplug programmer out while still using PORT B5,B6.
Still Not displayed properly .
2) I tested them with move PIN B5 AND B6 to others B5 to C2 ,B6 to C5
Still Not displayed properly.
I think B5 and B6 not effect them because as I mentioned on last quote.
It work fine if I connected RW to some pin port IO.
then #define USE_RW_PIN 1
It should not display properly only one case when //#define USE_RW_PIN 1 then connect RW PIN to Ground.
Any comment or suggestion please let do us know.
Thank you |
|
|
subi
Joined: 29 Aug 2010 Posts: 24
|
A/D using problem with PIC18Fxxxx |
Posted: Mon Sep 20, 2010 10:22 am |
|
|
Hi Everybody!
I would like to use the A/D converter of PIC but I have a problem. So when I used A/D converter with PIC16Fxxx I have the #device *=16 in the program. I would like to ask that have I to use this line with the PIC18Fxxx (PIC18F4321) ?
Thanks your help.
Best regard,
Subi |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Sep 20, 2010 10:31 am |
|
|
Subi,
New questions should go into a new thread. |
|
|
|