View previous topic :: View next topic |
Author |
Message |
scottc
Joined: 16 Aug 2010 Posts: 95
|
LCD en & RS lines Constant activity |
Posted: Sun Sep 12, 2010 3:15 am |
|
|
I have a 20x2 chr LCD module that is working good in 4bit mode running
on the upper nibble of port B.
I connected my Logic Analyzer to the EN & RS pins to check the timing
during writes to the display so as to verify my code.
I notice that the EN line is producing a nice Square Wave all the time
of right about 1ms. The EN line is connected to RC1 on my pic 18f2331.
I am curious to know if this is normal. It was my understanding that the
EN line should only toggle when there is a write to the display. It don't
seem right that it should be doing this all the time.
Beyond that the display works good, no issues writing to it at all. The 1ms
square wave is present regardless if the display is connected or not.
Thanks Scott |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 12, 2010 12:22 pm |
|
|
Make a small test program that only has a while(1) statement in main()
and nothing else. Don't enable PWM, don't enable the WDT, don't allow
any Wizard code to be placed inside main(). Run that program. Do you
still get the 1ms period square wave ? If not, then something in your
previous program is causing it. Start by commenting out blocks of code
in your program. Compile and test in hardware. When the 1 ms signal
goes away, then you have found the block of code that is the problem.
Then comment it out by smaller and smaller sections, testing each time,
until you find the offending line of code. In other words, trouble-shoot
the problem. |
|
|
scottc
Joined: 16 Aug 2010 Posts: 95
|
|
Posted: Sun Sep 12, 2010 7:57 pm |
|
|
Hi PCM, I have isolated the issue with the EN line toggling to I believe
what I think might be an issue with the compiler.
The issue happens when the LCD routine gets polled from main, while
running in a while loop.
The following code works flawless. No weirdness with EN/RS lines
Code: |
void Display_Stuff(void)
{
Lcd_cmd( LCD_LINE1 );
Write_LCD("This is a Test");
}
void main()
{
set_tris_b(0b00001101);
set_tris_c(0b11000000);
setup_oscillator(OSC_8MHZ|OSC_Normal);
LCD_START(); //Init the LCD
Display_Stuff();
}
|
The following code produces the ringing 1ms constant pulse on the
EN Line, Pin RC0
Code: |
void Display_Stuff(void)
{
Lcd_cmd( LCD_LINE1 );
Write_LCD("This is a Test");
}
void main()
{
set_tris_b(0b00001101);
set_tris_c(0b11000000);
setup_oscillator(OSC_8MHZ|OSC_Normal);
LCD_START(); //Init the LCD
while (true)
{
Display_Stuff();
}
}
|
In the above Main is calling DisplayStuff from an infinite loop. It is only when calling the display from a infinite loop that the problem happens.
I am a bit stumped on what to do, because in order to keep my code
running its going to need to run from main in a while loop along with
the other functions that get called from Main.
Any ideas ?
Thanks Scott. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Sep 13, 2010 1:52 am |
|
|
Er. The 'example' code, you show, is continuously writing to the screen. Of course the EN line is going to have a continuous signal doing this. If you stop writing to the screen the signal will stop. ie:
Code: |
void Display_Stuff(void)
{
Lcd_cmd( LCD_LINE1 );
Write_LCD("This is a Test");
}
void main()
{
set_tris_b(0b00001101);
set_tris_c(0b11000000);
setup_oscillator(OSC_8MHZ|OSC_Normal);
LCD_START(); //Init the LCD
while (true)
{
Display_Stuff();
delay_ms(1000); //Imagine your code is going and doing something else.
}
}
|
You should see little bursts of activity, separated by one second gaps.
Best Wishes |
|
|
|