Jump to content
Sign in to follow this  
Stringer

LCD plug-in

Recommended Posts

Okay, I have a LCD with following configuration:

 

RA0 = Data0

RA1 = Data1

RA2 = Data2

RA3 = Data3

RA4 = Data4

RA5 = Data5

RE0 = Data6

RE1 = Data7

RE2 = RS

RC0 = enable

RC1 = RW

 

Problem is, that real device works just fine, but the plug-in doesn't say anything !

 

I have included following to my code's start:

	adcon1=0x6;
adcon0=0; //ensure that AD module is offline

Share this post


Link to post
Share on other sites
Guest Dave

Stringer,

 

I've seen no other reports of LCD plugin not working.

 

I have had one report that the timing was slightly different to an actual device, my explanation to that is that different manufactures have used slightly different timing - this affected the display startup.

 

Things to check/try:

1) Check that setting->clock rate has the correct clock rate for the target device, plugins use this to compute their timings relative to processor clock.

2) Try the sample program from the Exmples page, by  Victor Golutvin, this one works with the LCD plugin for sure.

3) Try the plugin sample program for LCD that gets installed in the SourceBoost directory. My two test programs are there that test most display function in both 4 bit and 8 Bit mode.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Yes, the plug-in example which came with IDE is working.

Also, my own code was working in my previous project, but pins have changed since then. They used to be as following:

 

RD0 = Data0

RD1 = Data1

RD2 = Data2

RD3 = Data3

RD4 = Data4

RD5 = Data5

RD6 = Data6

RD7 = Data7

RE1 = RS

RE0 = enable

RE2 = RW

 

I have checked the clock rate to be 3.579550MHz.

Share this post


Link to post
Share on other sites
Guest Dave

Stringer,

 

As far as the plugin is concerned it should not matter which port is used for any of the connections. All the pins are treated as individual connections.

 

Consider changing the supplied example program so that it just uses the ports you have specified - to get away from any other differences in your code.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Or mayby you could just take a look at the code and say if there is something wrong regarding the plug-in:

 

#include <system.h>
#include "lcd.h"
#include "misc.h"

LCD::LCD()
{
  Reset();
}

void LCD::Reset()
{
  trisa = 0x0;
  trise = 0x0;
  trisc &= ~11b;
  delay_ms( 20 );
  
  writeDelayType=INITIALIZING_WAIT;
  write_instruction( 0x30 );   //Data interface, lines, font size
  delay_ms(5);
  write_instruction( 0x30 );   //Data interface, lines, font size
  delay_us(150);
  write_instruction( 0x30 );   //Data interface, lines, font size
  
  writeDelayType=NORMAL_WAIT;
  
  WaitForNotBusy();
  write_instruction(0x38); //111000b

  write_instruction(0x08); //1000b
  write_instruction(0x06); //110b
  write_instruction(1111b); //1111b
  write_instruction(0x80); //10000000b

  clear();
}


void LCD::write(char kirjain2)
{
  WaitForNotBusy();
  
  asm bcf _portc, 0; 
  asm bcf _portc, 1; 
  asm bsf _porte, 2;
  asm nop;

  trisa = 0x00;
  trise = 0x00;

  porta = kirjain2;
  porte = (kirjain2 & 11000000b) >> 6 | 100b;
  asm nop;
  asm nop;
  asm nop;
  asm nop;
  asm nop;
  enable_data();
}

void LCD::enable_data()
{
  asm bsf _portc, 0;
  delay_us( 25 );
  asm bcf _portc, 0;
}

void LCD::write_instruction(char instruction)
{
  WaitForNotBusy();

  asm bcf _portc, 0; 
  asm bcf _portc, 1; 
  asm bcf _porte, 2;
  
  trisa = 0x00;
  trise = 0x00;

  porta = instruction;
  porte = (instruction & 11000000b) >> 6;

  asm nop;
  asm nop;
  asm nop;
  asm nop;
  asm nop;
  
  enable_data();
}

void LCD::clear()
{
  write_instruction(00000001b);
}

void LCD::WaitForNotBusy()
{
  if( writeDelayType != INITIALIZING_WAIT ) 
  {
asm bcf _portc, 0; 
asm bsf _portc, 1; 
asm bcf _porte, 2;
  trisa = 0xFF;
  trise = 11b;

     asm bsf _portc, 0
        asm nop;
        asm nop;
     
     while( porte & 10b ) 
     {
        asm bcf _portc, 0
        asm bsf _portc, 0
        asm nop;
        asm nop;
     }
     asm bcf _portc, 0
  }
}

 

Some of the code are from the example more or less directly :P

Share this post


Link to post
Share on other sites
Guest Dave

Stringer,

 

I don't expect to see much from the code, as you say it works with the actual hardware, so it can't be far wrong.

 

I will maybe test tomorrow, if you still have problems.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Unfortunally I don't have much to update regarding the problem.

 

I converted the plug-in example for PIC16F877 (what I'm using), but it worked just fine. I also changed control port to E, but no affect from that either. I even tried to change the Setup code so that there would have had been same instruction codes.

 

When my code writes a data to the data port, it doesn't filtter out the two upper bits regarding portA. Perhaps I should add "data & ~11000000b" there? I'll try that once I get back to home. What happens in the simulation if portA is overflowed?

Share this post


Link to post
Share on other sites
Guest Dave

Stringer,

 

I also changed control port to E, but no affect from that either. I even tried to change the Setup code so that there would have had been same instruction codes

 

What does this mean - work with new target or not ?

 

Regards

Dave

Share this post


Link to post
Share on other sites
Guest Dave

Stringer,

 

I believe the The problem is RA4 is not a pushpull drive, check the device data sheet.

 

The LCD is not getting the correct logic levels on RA4, yo can measure them with DVM plugin.

 

So the simulator and LCD plugin are acting just like the real devices :) . I guess your actual hardware either has a pullup resistor or the display has one built in.

 

What you need is a pullup resistor plugin, which we don't have.

 

So don't use RA4, use another port instead.

 

Regards

Dave

Share this post


Link to post
Share on other sites
Guest Dave

Stringer,

 

Another option, use the display in 4 bit interface mode.

That way you will only need to used RA0 to RA3.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Youre right! Thats it.

 

I didn't build any pullups, so there must be pullup in the LCD.

 

I guess this could also solve the other problem with the SRAM? Altough that was a real device.

 

BTW. thanks!

Share this post


Link to post
Share on other sites

I'm seeing the same problem you have.  Works for a real LCD & PIC16F877, but doesn't work on the Plug-in.  The sample program works with the plug-in, but my code doesn't work with the plug-in.  I've tried about everything... still no luck.  

It would be a helpful debugging tool if it works.

 

Did you ever resolve this???

Share this post


Link to post
Share on other sites
Guest Pavel
I'm seeing the same problem you have.  Works for a real LCD & PIC16F877, but doesn't work on the Plug-in.  The sample program works with the plug-in, but my code doesn't work with the plug-in.

If I understand you correctly you have some code or project that works with real LCD and doesn't work with the LCD plugin. If that's the case can you zip the whole project directory and send it to support@picant.com. We'll be able to solve this problem once we can reproduce it.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Did you ever resolve this???

 

Not really, as there is no way to turn off the open drain output of RA4 in the simulator. I just change the RA4 to RB4 with compiler directive when using simulator. Another way Dave mentioned would be using only 4 bit interface to the display, which would also give you couple extra pins as a plus.

 

But in future I'm going to use only serial interface displays from Matrix-Orbital (http://www.matrixorbital.com), because they need only two pins and have features which make my own code much shorter. As a plus, they have quite many different variations (colors & sizes) about their displays.

Share this post


Link to post
Share on other sites

I've found and issue that caused some of the problem.  UART code that hung the simulator unexpectedly.  The LCD does work if I comment out any send command on the hardware UART.  Commands where the UART only talks when talked to can be used.  

Unfortunatly this brings up a worse bug.  The UART worked fine untill I used a long integer in an AD read.  I've rechecked and if I leave adresh & adresl as bytes the UART's fine.  But, in order to scale the AD I need to combine them into one 16 bit integer.  As soon as I even declare the 16 bit integer the UART's baud rate is off.  With optimization at medium or off, I get one clear character back, and that's it.  The AD's long integer and the UART code have nothing to do with each other, makes no sense why it's happening (for now).  The UART has never given me problems before.  8051's etc. don't seem anywhere near as buggy as the PIC.

I'm looking through the assembled code to see where the bug is now.  The UART can't be simulated (I assume...), so this may be slow going.  Any ideas.

Share this post


Link to post
Share on other sites
Guest Pavel
8051's etc. don't seem anywhere near as buggy as the PIC

In my practice in absolutly most cases when I start blaming hardware or software I sooner or later find that that was me who made an error.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Guest Dave

Ziffy1,

 

I've found and issue that caused some of the problem.  UART code that hung the simulator unexpectedly.  The LCD does work if I comment out any send command on the hardware UART.  Commands where the UART only talks when talked to can be used. 

 

The simulator currently does not simulate the hardware UART. The registers exist, but no status bits will change state.

 

So if you have code that is waiting for UART status bit to change state then your code may hang under the simulator, but the simulator should still function, you should be able to stop and start the code execution using the controls in the debugger. If this is not the case, then we have a problem.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...