All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Embedded Systems and Microcontrollers

Notices

Embedded Systems and Microcontrollers Discussion forum for projects and working with embedded systems and microcontrollers (FPGAs, PICs, AVRs). Get help with hardware issues and embedded programming.

Reply   Post New Thread
 
Thread Tools Display Modes
  #1  
Old 05-05-2012, 12:40 AM
dmarciano dmarciano is offline
Junior Member
 
Join Date: Oct 2007
Posts: 21
Default Suggestion on table lookup for LCD display

I'm going to be using a Hantronix LCD in a project and this requires sending each column of pixels one at a time. I was planning on using a lookup table to send each letter or word. However this is my first time using lookup tables so I'm hoping someone can provide a suggestion. This code is simplified and was designed to help me learn lookups. Basically this code should read the hex code for the letter 'H'. After loading each byte the code jumps to a section which will actually send it to the LCD and then continue the loop. Once it has read all the data it should loop back to 'Start' (at least in this test version)

Code:
Start	movwf	tt,0
		movlw	low(H_CHAR)
		addwf	tt,0,0
		movwf	TBLPTRL,0
		movlw	high(H_CHAR)
		movwf	TBLPTRU,0
lpl		tblrd	*+
		movlw	.153
		CPFSLT	TABLAT
		GOTO	Start
		GOTO	Send
		
Send	movf	TABLAT,0,0
		movwf	PORTA
		GOTO	lpl

H_CHAR	db	0x00,0xfe
        db  0x10,0x10
		db  0xfe,0x99
Select All
My problem is figuring out when it has read all the data. I was think of using 0x99 but realized I can't because if I wanted to enable all the pixels in a single column that would be 0xFF which is the highest, and if I wanted a column with no pixels on I would need to send 0x00, so any number in between these two values is possible.

What is a good way so determine when I have read all the data in the 'H_CHAR' table (in this example)? The 0x99 is not part of the actual data being sent to the LCD screen. After reading the last 0xFE and jumping to 'Send', when it returns to the 'lpl' loop the code should somehow be able to figure out/know that all the data was read.

This table is only 5 bytes, but some may be more and some may be less so it would help to have a single way of detecting this. Any help would be greatly appreciated. The application note for the LCD I'll be using can be found here and on the last few pages it give a sample code, albeit the code is in 8051 assembly which I'm not familiar with.
Reply With Quote
  #2  
Old 05-05-2012, 03:02 AM
ErnieM's Avatar
ErnieM ErnieM is online now
Senior Member
 
Join Date: Apr 2011
Location: Lon Guyland, Noo Yawk
Posts: 5,195
Default

I did a display similar to this a few years ago. Character bit patterns were handled as simple uniform sized bitmaps, so all you need do is know the character size and the character code you want and you can compute an offset into an array.

I did spend much time on this and while I had a nice library of functions, I've abandoned that effort after finding simple black & white displays are not substantially cheaper then color displays.

I now just use the color ones and the excellent, free graphics object library from Microchip.
__________________
“Freedom is never more than one generation away from extinction. We didn’t pass it to our children in the bloodstream. It must be fought for, protected, and handed on for them to do the same, or one day we will spend our sunset years telling our children and our children’s children what it was once like in the United States where men were free.”
Reply With Quote
  #3  
Old 05-05-2012, 03:44 AM
dmarciano dmarciano is offline
Junior Member
 
Join Date: Oct 2007
Posts: 21
Default

On Microchips website the graphics library is listed as only working with PIC24/dsPIC and PIC32, while I'm using the PIC18F46K22. I already have this chip and the Hantronix screen so I'd rather stick with them since they are sufficient for what I'm doing and I already have them in hand.

I'm not sure exactly what you mean by using sized bitmaps along with any array to display character on the Hantronix screen. This is the first time I'm using an LCD screen so maybe I'm missing something. Do you have an resources that you could point me to that will explain how to use your way, or the way I was trying to do it, for the type of application I'm working on.

Every time I try to Google table lookups they are about changing programming memory or the user has a special code at the end of the table they can check for; which I can't do for the reasons already stated. Is there a function for returning the size or element count of a lookup table?
Reply With Quote
  #4  
Old 05-05-2012, 10:57 AM
Markd77's Avatar
Markd77 Markd77 is offline
Senior Member
 
Join Date: Sep 2009
Location: Birmingham
Posts: 2,783
Blog Entries: 1
Default

What I've done in the past is make the first byte of each array the length.
Reply With Quote
  #5  
Old 05-05-2012, 08:11 PM
ErnieM's Avatar
ErnieM ErnieM is online now
Senior Member
 
Join Date: Apr 2011
Location: Lon Guyland, Noo Yawk
Posts: 5,195
Default

I make fonts from bitmaps of the same size placed into an array and padded out do each character starts on an even byte field. I used this structure for fonts:
Code:
typedef struct
{
    rom char FirstFont;            // first ASCII symbol defined
    rom char LastFont;            // last ASCII symbol defined
    rom char DefaultFont;        // If nothing available...
    rom char FontWidth;         // font width in pixels
    rom char FontHeight;        // font height in pixels
    rom char BytesPerCharacter;    // bytecount for a single character
    rom char *Bitmap;             // first byte of ROM bitmap 
} font;
Select All
Then a font file would look like so:
Code:
rom char Font5x7bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00,        // Space    32
    0x00, 0x00, 0x4F, 0x00, 0x00, 0x00,        // !        33
    0x00, 0x07, 0x00, 0x07, 0x00, 0x00,        // "        34
...
...
    0x00, 0x01, 0x02, 0x04, 0x00, 0x00,        // `        96
    0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00        // (box)    97
};

rom font _Font5x7 = 
{
      32,        // first ASCII symbol defined
      97,        // last ASCII symbol defined
      97,        // If nothing available...
      6,         // font width in pixels
      8,         // font height in pixels
      6,        // 6 bytes in each character definition
      Font5x7bits
};
Select All
Obviously there are a bunch of routines behind this, and the bad news is since this is an abandoned work whatever documentation existed was never completed and pretty much lost. I think I did a brief explanation of the GLCD functions but that's gone. I also did a VB applet to take B&W bitmaps and convert to C style byte arrays, that's also gone.

I do have one of the last projects I did and I've included it in case you wish to reverse engineer some of it.
Attached Files
File Type: zip GLCD.zip (308.5 KB, 2 views)
__________________
“Freedom is never more than one generation away from extinction. We didn’t pass it to our children in the bloodstream. It must be fought for, protected, and handed on for them to do the same, or one day we will spend our sunset years telling our children and our children’s children what it was once like in the United States where men were free.”
Reply With Quote
  #6  
Old 05-08-2012, 08:30 PM
nigelwright7557 nigelwright7557 is offline
Senior Member
 
Join Date: May 2008
Posts: 384
Default

I have always used the same number of bytes for each character.
Reply With Quote
Reply   Post New Thread

Tags
, , , , , ,


Related Site Pages
Section Title
Worksheet Microcontroller principles
Worksheet Digital display circuits
Textbook SPICE models : Diodes And Rectifiers


Similar Threads
Thread Thread Starter Forum Replies Last Post
PIC Random Lookup Table mark squared Embedded Systems and Microcontrollers 4 10-22-2010 04:34 AM
Problems with program counter and lookup table wannaBinventor Embedded Systems and Microcontrollers 3 08-21-2010 10:21 PM
C lookup table help blackmamba Embedded Systems and Microcontrollers 6 12-07-2009 05:40 PM
LCD Display - Can't show characters BillGeek Embedded Systems and Microcontrollers 12 10-27-2009 01:33 PM
The Seven Segment Display zhhgw Homework Help 8 01-13-2008 04:55 AM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:07 PM.


User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License.
Powered by vBulletin
Copyright ©2000 - 2014, vBulletin Solutions, Inc.