Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 26, 2024, 05:35:45 17:35


Login with username, password and session length


Pages: [1]
Print
Author Topic: Help with Proteus and LCD displays (Busy Flag)  (Read 20386 times)
0 Members and 1 Guest are viewing this topic.
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« on: November 17, 2007, 02:23:32 02:23 »

I am using a 16F877 Pic connecting to a 4x20 LCD display in Proteus 7.1 Sp2. My .asm program I wrote works great with hardcoded delays in it for the LCD. I wanted to give using the Busy Flag for the LCD a try but no matter what I do it will not work. After the Check for the busy flag the Pic cannot write to the display again. I used many examples found on the internet but they all end up not working. I'm wondering if this is just a bug with proteus. I have not tried to build the circuit yet. Also, would like to know if maybe I should put the RS, RW, E control lines on a separate port instead of including it with my 4 bit data/address lines? I have RW on portb 6, RS, on portb 4, and E on portb 5. Data lines are on 0,1,2,3 of portb.

I can put up the code if it would be helpful but I am just wondering if anyone else has been successful using a LCD Busy Flag with proteus? Also if I should maybe not put everything on one port (B). I doing all this in assembly. I not a hardcore assembly language programmer but I'm learning fast. I've do alot of hardware programming in other languages.

Help or Advice is greatly appreciated.

Thanks,
Alienbeing 
Logged
zuisti
Senior Member
****
Offline Offline

Posts: 409

Thank You
-Given: 242
-Receive: 780


« Reply #1 on: November 17, 2007, 08:56:48 08:56 »

I am using a 16F877 Pic connecting to a 4x20 LCD display in Proteus 7.1 Sp2. My .asm program I wrote works great with hardcoded delays in it for the LCD. I wanted to give using the Busy Flag for the LCD a try but no matter what I do it will not work. After the Check for the busy flag the Pic cannot write to the display again.
....
I can put up the code if it would be helpful ...

Hi Alienbeing,

Please post your Proteus project (simplified if you want) in a zipped or rar-ed form to rapidshare, including also the asm with the working hardcoded delays.
Sorry but I don't have a program with busy checking but  I'm working with PICs also in assembly, hope I can help you.

However, my quick ideas are here:
1. Also for check only the busy flag (bit 7) you must read back the whole byte (both nybbles) !!
2. Do you make the proper port (data pins) direction alterings ? (only the busy checking  needs portb 0...3  as inputs)   

zuisti 
Logged
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« Reply #2 on: November 18, 2007, 02:13:56 02:13 »

Thanks, I'll package up everything. Assembly code with the hardcoded delay, and the version with the added Bit Flag check, as well as the Proteus project. I was thinking maybe I might not be reading in the nibbles correctly bacause I've been getting LCD controller errors in proteus like this "[HD44789] Attempted to read after writing a single nibble". The code I've used for the BF check was written by someone else. Found it searching the internet. I step through it proteus and it seems to perform correctly (BF check code) after 7 passes through the code then on the 8th pass it gives me that error. I guess what is making this difficult is running this in 4bit mode. Got to be how I'm processing the nibbles somwhere.
I'll get the stuff zipped or rared up shortly.

Thanks,
Alienbeing

Edited:
Strange behavior in Proteus.

Heres what is happening and probably should not. Think it could be a problem in Proteus.
LCD_DATA = Portb
LCD_DATA_TRIS=trisb

CLRF    LCD_DATA                  ;Portb is Cleared 00000000
BANK1                                  ;switch to Bank0
MOVLW   B'00001111'              ; Set PORTB for input, W now contains 00001111 which is good.
MOVWF   LCD_DATA_TRIS       ; Move W to TRISB, Trisb now contains 00001111 which is good too.
BANK0                                  ;switch to Bank 0
BCF     LCD_DATA,4           ; Set RS to low (LCD Command Mode) RS is already low, but PortB now contains 00001111. Is this right? LCD pins 0-3 are 1
BSF     LCD_DATA,6           ; set RW to high to read busy flag, PortB now contains 01001111 RW pin on LCD is enabled, good
BSF     LCD_DATA,5            ; LCD E-line High, Portb is now 01101111, E pin on LCD is Enabled, good    
BCF     LCD_DATA,5                 ;SET E To Low, Portb is now 01000000, ******What happend here?*******Should this be 01001111?*****
SWAPF   LCD_DATA, W            ; W now contains 11110100, ****Think something is really wrong here*******

This makes me think Proteus is buggy doing this stuff. Or maybe it just their Debug Register window is not working right, but because of the way the program is working I think Proteus it's not running the code the way it should in the simulation. Maybe I should upgrade to a newer version? Using 7.1 Sp2 right now.

Thanks,
Alienbeing
« Last Edit: November 18, 2007, 04:11:04 04:11 by Alienbeing » Logged
zuisti
Senior Member
****
Offline Offline

Posts: 409

Thank You
-Given: 242
-Receive: 780


« Reply #3 on: November 18, 2007, 10:29:36 10:29 »


Hi Alienbeing,
Quote
I'll package up everything....I'll get the stuff zipped or rared up shortly.
Please upload it to Rapidshare beacuse you CAN attach a file in your post but you cannot see it (you are a newbie yet)

Some answers to you:

Quote
BCF     LCD_DATA,4 ; Set RS to low (LCD Command Mode) RS is already low, but PortB now contains 00001111. Is this right? LCD pins 0-3 are 1
Yes, it is right beacuse the LCD data pins are set only after an E pulse.

Quote
BCF     LCD_DATA,5 ;SET E To Low, Portb is now 01000000, *What happend here?*Should this be 01001111?
The E is working at falling edge, so this is the moment of the set of data pins. I think Proteus  cannot akcept it now, only later...

Quote
SWAPF   LCD_DATA, W ; W now contains 11110100, *Think something is really wrong here*
No, this is the right result: Busy flag in the W.7, it is set yet (1), we are waiting, but now we MUST be read also the 2nd nybble, so we must store the Busy value temporaly for testing later, after the second dummy nybble read (and ... test again)

Quote
This makes me think Proteus is buggy doing this stuff...Maybe I should upgrade to a newer version? Using 7.1 Sp2 right now
I don't agree, however I'll try it...

Do you apply the proper LCD init commands ? It is not so easy at 4 bit mode. There are also nybble-only commands...

I'm waiting for the download link here.

zuisti
Logged
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« Reply #4 on: November 18, 2007, 02:15:47 14:15 »

I'll package it up later today. Have to leave my home shortly and go a few places. I tried changing one of the PIC parameters to randomize data memory and results are alittle different but still have the same problem with the busy flag code. I will up the code (asm), Proteus project file, and a text file containing the GPS Nema sentences that can be copied and pasted into the virtual terminal while the proteus is running. The simulation uses RS232 to transfer GPS Nema sentences from a GPS module and then the PIC parses the nema sentences to grab the relevent parts of the NEMA sentences that are then displayed on the LCD. All works well with hardcoded delays. I am just trying to use the Busy flag to speed things up abit. My LCD display updates at about every second during the reading of the NEMA sentences as I display the UTC time coming from the GPS which shows Hours, minutes, and seconds. As well as display date, and lat/long coordinates. If you put a ; in front of the call to Check the busy flag to skip it from being called it will work OK. I'll put a comment there. Otherwise you will have to use the Delay routine before the Data is sent to the LCD to make it work good.
I'll put up the code and the rest on rapidshare for you later today as I have to get ready to leave now. Thanks for your help as it is appreciated. I was just going to uninstall Proteus and try installing a newer version.

Thanks,
Alienbeing
Logged
localcrack
Active Member
***
 Muted
Offline Offline

Posts: 173

Thank You
-Given: 64
-Receive: 21



« Reply #5 on: November 18, 2007, 05:41:10 17:41 »

Proteus LCD module has a problem in BUSY Flag checking. I also suffer from the same proble.
Please give small Delay rather then checking BUSY flag. that solves your problem
Logged
zuisti
Senior Member
****
Offline Offline

Posts: 409

Thank You
-Given: 242
-Receive: 780


« Reply #6 on: November 19, 2007, 12:22:31 12:22 »

Proteus LCD module has a problem in BUSY Flag checking.

Hi localcrack (and all others),
I don't agree with you. Proteus is great, and ... the Sonsivri is also great  Wink

If you are using the proper LCD init commands and a right asking for the Busy flag, it is working as well (also in 4 bit mode).

I wrote a small asm program to demonstrate this in Proteus (attached). It is a simple 16 bit counter, its running value is
displaying in decimal and also in hex form. The working DSN and the source are included. Try it!

I must say almost all source examples on the net are erroneous about this question.

zuisti
Logged
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« Reply #7 on: November 19, 2007, 01:06:12 13:06 »

Thanks will give this a look. Seems there are alot of examples on the net on how to check the Busy flag but they are not similar in ways that make it consusing as to how to correctly implement it. So far I haven't found a way that works without generating errors in proteus. It does look as the problem is how the nibbles are processed in 4 bit mode. I'll be uploading my code today so anyone else can check it out.

Thanks,
for your help, greatly appreciated.

Alienbeing
Logged
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« Reply #8 on: November 19, 2007, 07:22:41 19:22 »

Thanks Zuisti,
Your code works great in proteus in your example. Mine was similar but not exactly. Still I have problems. Right not running your Busy_Flag code it works for about the first 6 characters displayed then it constantly loops in the Busy Flag code afterwards. Haven't been able to figure out why yet. Still receiving LCD controller errors with Trace=2 set in the LCD parameters. Error is "attempted to read after writing a single nibble". I'm trying to debug this by checking my variables and registers to see what might be causing it. I've been running my PIC with a 20Mhz clock source but took it down to 4MHz and still have the same problem. I'm at work so I don't have alot of time to play around with the code right now. But later tonight I get into it some more. It's almost working good. Just getting stuck in a loop because of the Busy Flag bit will not clear for some reason.

Thanks,
Alienbeing
Logged
zuisti
Senior Member
****
Offline Offline

Posts: 409

Thank You
-Given: 242
-Receive: 780


« Reply #9 on: November 19, 2007, 07:36:18 19:36 »

Hi,
I'm waiting for your project to study it...
zuisti
Logged
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« Reply #10 on: November 19, 2007, 09:16:48 21:16 »

Will put it up tonight in a few hours. I'm still at work. After work I take Karate lessons. Then I'll be home to put this stuff in a zip or rar for you. Probably put up on Rapid share.

Thanks for offering to take a look at it.

Alienbeing
Logged
senthils2k
Junior Member
**
Offline Offline

Posts: 97

Thank You
-Given: 41
-Receive: 6


« Reply #11 on: August 26, 2008, 05:08:56 05:08 »

Connect only d4 ...d7 to port
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC