Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Can Time be reduced to update LCD

Status
Not open for further replies.

cool.man

Full Member level 6
Full Member level 6
Joined
May 29, 2008
Messages
323
Helped
42
Reputation
84
Reaction score
29
Trophy points
1,308
Location
Earth
Visit site
Activity points
3,307
Hi guys
I am writing a program,which shows some readings on lcd. For testing purpose i am showing 0-9 numbers on LCD as you can see on the image.

20141217_124803.jpg

i have write a code in ccs c compiler.the code is
Code:
#include <18f2431.h> 
#fuses HS,NOLVP,NOWDT                                                 
#USE DELAY (CLOCK=4M)                                                
                                                                    
#define data_pin     PIN_A3//data pin for LCD/keypad.              
#define clock_pin    PIN_A2//clock pin for LCD/keypad.            
#define strobe_lcd   PIN_A1 //strobe pin for LCD.                  
                                                                             
////////////////////////////////////////////////////////////////////////////////
//*******************************LCD (BLUE SKY)*********************************  
////////////////////////////////////////////////////////////////////////////////


//  -------------------------------------------------------------------------   
//  |Position|Position|Position|Position|Position|Position|Position|Position|
//  |   No   |   No   |   No   |   No   |   No   |   No   |   No   |   No   |
//  |   21   |   20   |   19   |   18   |   17   |   16   |   15   |   14   |
//  |        |        |        |        |        |        |        |        |
//  -------------------------------------------------------------------------    
//  |Position|Position|Position|Position|Position|Position|Position|Position|
//  |   No   |   No   |   No   |   No   |   No   |   No   |   No   |   No   |
//  |   13   |   12   |   11   |   10   |   09   |   08   |   07   |   06   |
//  |        |        |        |        |        |        |        |        | 
//  -------------------------------------------------------------------------
//  |////////|Position|Position|Position|Position|Position|Position|////////|
//  |////////|   No   |   No   |   No   |   No   |   No   |   No   |////////|
//  |////////|   05   |   04   |   03   |   02   |   01   |   00   |////////|
//  |////////|        |        |        |        |        |        |////////|
//  -------------------------------------------------------------------------  
                                              
////////////////////////////////////////////////////////////////////////////////


int1 lcd_data[176]={
                // dot, g, f, e, d, c, b, a 
                     0, 0, 0, 0, 0, 0, 0, 0,//00 position
                     0, 0, 0, 0, 0, 0, 0, 0,//01 position
                    
                     0, 0, 0, 0, 0, 0, 0, 0,//02 position         
                     0, 0, 0, 0, 0, 0, 0, 0,//03 position
                     0, 0, 0, 0, 0, 0, 0, 0,//04 position
                     0, 0, 0, 0, 0, 0, 0, 0,//05 position                            
                                                                      
                     0, 0, 0, 0, 0, 0, 0, 0,//06 position
                     0, 0, 0, 0, 0, 0, 0, 0,//07 position                
                     0, 0, 0, 0, 0, 0, 0, 0,//08 position
                     0, 0, 0, 0, 0, 0, 0, 0,//09 position
                                                                 
                     0, 0, 0, 0, 0, 0, 0, 0,//10 position
                     0, 0, 0, 0, 0, 0, 0, 0,//11 position
                     0, 0, 0, 0, 0, 0, 0, 0,//12 position
                     0, 0, 0, 0, 0, 0, 0, 0,//13 position
                    
                     0, 0, 0, 0, 0, 0, 0, 0,//14 position
                     0, 0, 0, 0, 0, 0, 0, 0,//15 position                                      
                     0, 0, 0, 0, 0, 0, 0, 0,//16 position                      
                     0, 0, 0, 0, 0, 0, 0, 0,//17 position                   
                                                                          
                     0, 0, 0, 0, 0, 0, 0, 0,//18 position                 
                     0, 0, 0, 0, 0, 0, 0, 0,//19 position
                     0, 0, 0, 0, 0, 0, 0, 0,//20 position           
                     0, 0, 0, 0, 0, 0, 0, 0,//21 position      
                    };
int seg_loop,c,b;
int segx[22]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
BYTE CONST segs_7[12]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6,0x00,0xce};//7-segment values of 0-9 
                                         
void lcd_print(void)
{
   seg_loop=0;                  
   do
   {                         
      output_high(clock_pin);//clock signal high                     
      output_bit(data_pin,lcd_data[seg_loop]);//data out              
      output_low(clock_pin);//clock signal low
      seg_loop++;                              
   }while(seg_loop<=175);
   
   output_low(strobe_lcd);//strobe signal low   
   output_high(strobe_lcd);//strobe signal high 
}                                           
                                                               
void main()
{                                                      
   segx[0]=9;segx[1]=8;segx[2]=7;segx[3]=6;segx[4]=5;segx[5]=4;
   segx[6]=3;segx[7]=2;segx[8]=1;segx[9]=0;segx[10]=1;segx[11]=2;
   segx[12]=3;segx[13]=4;segx[14]=5;segx[15]=6;segx[16]=7;segx[17]=8;
   segx[18]=9;segx[19]=0;segx[20]=9;segx[21]=8;   
                                                          
   while(TRUE)
   {                                                                                                 
      output_toggle(PIN_C0);//just for checking the loop time (approx ~24mS)
                                                               
      c=175;                                                  
      for(seg_loop=0;seg_loop<22;seg_loop++)      
      {                    
         b=0b10000000;
         do                                            
         {
            lcd_data[c--]=segs_7[segx[seg_loop]] & b;//storing segments data 
                              //bit-by-bit in an array for sending to LCD.
            rotate_right(&b,1);                 
         }while(b!=0b00000001);
         c--;
      }                                                           
      
      output_high(PIN_C1);//just for checking the loop time (approx ~10mS)        
      lcd_print();
      output_low(PIN_C1);//just for checking     
   } 
}
Everything is working fine.I just want to know that can i reduce the whole process time below 24mS?
Is there any possibility to reduce the code and time?
 

Your program has to loop over 3,800 times to write to all the segments so with a 4MHz clock it will always be fairly slow. Your only option is to increase the clock speed or adjust the program so only the necessary number of digits are updated. You do not show how the information to display will be set when you go from fixed numbers to 'live' ones so you might be able to individually address the digits so only ones needing attention are updated.

Brian.
 

One thing you can do is to preprogram all 8 bytes for each digit (a character mask table), so you don't need to scan the bytes for valid bits. You just copy the correct 8 bytes into the output array from the stored segment table.

Can you address the individual digits, or do you need to output the whole 176 byte sequence every time?

Have you got any datasheet of your display?
 

@betwist, Currently i am only checking that how LCD print data using fixed numbers. After this i will use live nos. I tried to update some of the segments to check if it works or not, its not working. I have to update all the segments whenever there is new data. So i think there is only 1 option (increase the freq form 4MHz) left.

@Gorgon Individual digits addressing is not possible.176 bytes sequence is must as far as i understand and checked it using different programming schemes. No i haven't got datasheet form the manufacturer.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top