View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
Problem with LCD |
Posted: Fri Jul 13, 2012 12:44 am |
|
|
Hi! I'm controlling LCD with 2 row, 16 symbols each. My controller is 18F4520. Everything works fine, but there is a small glitch. When I turn on the power nothing happens. So I have to turn it off and next again to turn on the supply. Next everything is OK. But I want to fix this. I turn on the WDT but without any success. I put 2 caps nearby the controller (100nF and 100uF electrolytic) - nothing. Do you have any idea what's causing this???
Thanks! |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
Re: Problem with LCD |
Posted: Fri Jul 13, 2012 12:59 am |
|
|
stoyanoff wrote: | Hi! I'm controlling LCD with 2 row, 16 symbols each. My controller is 18F4520. Everything works fine, but there is a small glitch. When I turn on the power nothing happens. So I have to turn it off and next again to turn on the supply. Next everything is OK. But I want to fix this. I turn on the WDT but without any success. I put 2 caps nearby the controller (100nF and 100uF electrolytic) - nothing. Do you have any idea what's causing this???
Thanks! |
Do you have a time-delay pull-up on MCLR?
(i.e. VCC <--- 100K -> MCLR <-- 100nF --> GND)??
Do you have a schematic you can post?
You should post a short example of your code (just enough to show the problem) as well as your compiler version.
Cheers,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Fri Jul 13, 2012 1:21 am |
|
|
Yes, I have 100b cap on MCLR, too. I`m using 2 74HCT373 buffs connected to port B. The hardware works fine. My program too. The problem is this small glich on first turn on. I think something cause controller blocking.
Code: |
#include <18F4520.h>
#FUSES H4,WDT128,WDT
#use delay(clock=40M)
void main()
{
restart_wdt();
initialLCD();
setup_adc_ports(AN0_TO_AN2);
setup_adc(ADC_CLOCK_INTERNAL);
while(1)
{
restart_wdt();
....................
}
}
|
So this is a part of my code. On this bug the LCD is not even initialized! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19480
|
|
Posted: Fri Jul 13, 2012 2:48 am |
|
|
_Pause_.
A lot of the 'clone' LCD's, take longer to wake up, than the original standard Hitachi chips. Also though, many LCD's, don't start to power up till the supply gets up to perhaps 4v, while the PIC starts powering up much earlier. The rise time of the LCD supply will be being made worse by the capacitors!.
So:
Code: |
#include <18F4520.h>
#FUSES H4,WDT128,WDT,PUT //PUT delays the PIC fractionally till the
//clock is stable
#use delay(clock=40M,restart_wdt)
//You need this, since there are significant delays in the LCD code.
void main(void) {
restart_wdt();
delay_ms(250); //Allow time for the LCD to actually power up
initialLCD();
setup_adc_ports(AN0_TO_AN2);
setup_adc(ADC_CLOCK_INTERNAL); //This is _not_ legal at 40MHz
//read the data sheet.
while(1) {
restart_wdt();
....................
}
}
|
Best Wishes |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Fri Jul 13, 2012 11:25 pm |
|
|
I fix it! The problem was elsewhere. As I said I`m using 2 74HCT373 buf to pass data to LDC with only 1 port. So this buffers must be set before starting the initialization procedure.
Ttelmah your code has good pratices in i which I can use. Thanks! |
|
|
|