|
|
View previous topic :: View next topic |
Author |
Message |
SugarD Guest
|
Better Algorithm for driving Custom LCD? |
Posted: Wed Dec 23, 2009 11:13 pm |
|
|
Hi, I am using PIC 18F65J90, which has built in LCD driver, to drive custom designed LCD that consists of multiple digits of 7 segment LCD's.
The LCD displays not only the numbers but also some letters that I can display using 7 segments.
When one uses module LCD, I know he can display multiple letters on the module using relatively small ROM space. He can just write,
Code: |
lcd_putc("AbCdEF");
|
However, when I have to write the same thing on the custom LCD, I have to write
Code: |
lcd_symbol(digit_map[A], digit1);
lcd_symbol(digit_map[b], digit2);
lcd_symbol(digit_map[c], digit3);
lcd_symbol(digit_map[d], digit4);
lcd_symbol(digit_map[E], digit5);
lcd_symbol(digit_map[F], digit6);
|
which takes too much program memory if i want to put a lot of them.
Is there any way I do the same compactly with costing less program memory??
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 23, 2009 11:25 pm |
|
|
Please don't start a new thread every time you have a new question on
using the 18F65J90 with 7-segment LCDs.
But to answer your question, look at the lcd_putc() function in this CCS
example file:
Quote: | c:\program files\picc\examples\ex_92lcd.c |
Also look at the lcd_putc() function in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=32774&start=8
If you have any questions, add them to this thread or your earlier thread. |
|
|
SugarD Guest
|
i tried but.. |
Posted: Thu Dec 24, 2009 1:49 am |
|
|
Sorry, I thought that the two topics were different.
I looked at the post you referred and modified them to suit my purpose, which didn't work.
Code: |
//main.c
#include<18F65J90.h>
#include<def_18F65J90.h>
#fuses intrc
#use delay(clock = 32000)
#define CLOCK_SPEED 32000
//****************DP*******G*********F*******E********D********C********B*******A***
#define DIGIT1 COM0+0, COM2+31, COM3+31, COM1+31, COM0+31, COM1+0, COM2+0, COM3+0
#define DIGIT2 COM0+2, COM2+1, COM3+1, COM1+1, COM0+1, COM1+2, COM2+2, COM3+2
#define DIGIT3 COM0+4, COM2+3, COM3+3, COM1+3, COM0+3, COM1+4, COM2+4, COM3+4
#define DIGIT4 COM0+6, COM2+5, COM3+5, COM1+5, COM0+5, COM1+6, COM2+6, COM3+6
const int8 DIGIT_MAP[10]= {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x27, 0x7F, 0x67};
// a b c d e f g h i j
const int8 Letter_map[22] = {0x77, 0x7C, 0x39, 0x5E, 0X79, 0X71, 0X00, 0X00, 0X04, 0X00,
// k l m n o p q r s t
0X00, 0X38, 0x00, 0x54, 0x5c, 0x73, 0x00, 0x50, 0x6d, 0x78,
// u v
0x1c 0x3e};
//#including function headers.
#include<key_check.h>
int lcd_pos = 0;
byte segments = 0;
void lcd_putc(char c) {
if(c=='\f')
lcd_pos=0;
else{
if((c>='0')&&(c<='9'))
segments=Digit_Map[c-'0'];
else if((c>='a')&&(c<='z'))
segments = Letter_Map[c - 'a'];
else if(c=='-')
segments = 0x40;
else if(c =' ')
segments = 0x00;
}
switch(lcd_pos){
case 1 : lcd_symbol(segments,DIGIT1); break;
case 2 : lcd_symbol(segments,DIGIT2); break;
case 3 : lcd_symbol(segments,DIGIT3); break;
case 4 : lcd_symbol(segments,DIGIT4); break;
}
lcd_pos++;
}
//Function used for initializing LCD
void LCD_init(void){
LCDPS = 0b0010100; //WFT = 0(Type A waveform), BIASMD = 0(1/4 bias),
//LCDA = 1(lcd drive module is active), WA = 1(write allowed), LP = 0000(prescaling = 8:1)
//LCDSEx definition
LCDSE0 = 0xFF; //SEG<7:0> All Segment control
LCDSE1 = 0B10011111; //SEG<15:8> do not use 11(pulse_out)
LCDSE2 = 0XFF; //SEG<23:16> All segment control
LCDSE3 = 0B11011101; //SEG<31:24>
LCDSE4 = 0B00000001;
//LCDCON setup
LCDCON = 0b10011011; // LCDEN = 1, /SLPEN = 1, WERR = 0,unimplemented, CS<1:0> = 00(Fosc/4), LMUX<1:0> = 11(use 4 commons)
LCDREG = 0B00111100;//Unemplemented, CPEN = 0, BIAS<2:0> = 111, MODE13 = 1, CKSEL<1:0> = 00(regulator disabled)s
}
void init_rtn(void){
lcd_init();
}
void main(void){
init_rtn();
printf(lcd_putc,"\fabcd");
while(1);
}
|
When I run the code, the LCD only displays the first letter.
I think there is something wrong with my printf statement.
Thanks |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|