CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Driving an LCD Display

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

Driving an LCD Display
PostPosted: Wed Nov 04, 2015 12:49 am     Reply with quote

Hi,
I am driving an LCD Display having 3 Rows (8-8-6 Digits).
I'm using 18f252 micro-controller with 4Mhz crystal.
Manufacturer and the image of the LCD is in the given link
http://lantiandz.en.made-in-china.com/product/FqPEbGfOCeVp/China-Display-Board-X110-.html
They have used
Quote:
HT1609L 2*40 channel LCD Driver IC



I have write a code to drive the LCD. The code is as follows
Code:

#include <18f252.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.

int1 lcd_data[176]={
    // dot, g, f, e, d, c, b, a
         0, 0, 0, 0, 0, 0, 0, 0,       // 21 position, Dot value -> No Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 20 position, Dot value -> Effect
                   
         0, 0, 0, 0, 0, 0, 0, 0,       // 19 position, Dot value -> Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 18 position, Dot value -> Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 17 position, Dot value -> Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 16 position, Dot value -> No Effect
                   
         1, 0, 0, 0, 0, 0, 0, 0,       // 15 position, Dot value -> No Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 14 position, Dot value -> Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 13 position, Dot value -> Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 12 position, Dot value -> Effect
                   
         0, 0, 0, 0, 0, 0, 0, 0,       // 11 position, Dot value -> Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 10 position, Dot value -> No Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 09 position, Dot value -> No Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 08 position, Dot value -> No Effect
                   
         0, 0, 0, 0, 0, 0, 0, 0,       // 07 position, Dot value -> No Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 06 position, Dot value -> Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 05 position, Dot value -> Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 04 position, Dot value -> Effect
                   
         0, 0, 0, 0, 0, 0, 0, 0,       // 03 position, Dot value -> Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 02 position, Dot value -> No Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 01 position, Dot value -> No Effect
         0, 0, 0, 0, 0, 0, 0, 0,       // 00 position, Dot value -> No Effect
                   };
                   
int1 out[8]={0,0,0,0,0,0,0,0};
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};

                     // 0  ,  1 , 2  , 3  , 4  , 5  , 6  , 7  , 8  , 9  ,Blank,P //
BYTE CONST segs_7[12]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6,0x00,0xce};


int seg_loop,seg_loop2,c,b;

void main()
{
   while(TRUE)
   {
      output_toggle(PIN_C0);
     
      //Data to be shown on LCD.
      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]=1;segx[21]=2;

      c=175;   //Total nos of segments in an LCD.

      for(seg_loop=0;seg_loop<22;seg_loop++) //This loop place the 7-segment
      {                                      // values of each digit.
         b=0b10000000;
         for(seg_loop2=0;seg_loop2<=6;seg_loop2++)
         {
            lcd_data[c-seg_loop2]=segs_7[segx[seg_loop]] & b;
            rotate_right(&b,1);
         }
         c=c-8;
      }
     
      for(seg_loop=0;seg_loop<=175;seg_loop++)  //This loop update all  the LCD
      {                                         //having 175 segments.
         output_bit(data_pin,lcd_data[seg_loop]);
         output_high(clock_pin);
         output_low(clock_pin);
      }
      output_high(strobe_lcd);
      output_low(strobe_lcd);
   }
}



This is working fine but the whole routine is taking 24mS to complete the process. I want to reduce the timings.

Is there a way to simplify the routine and timings?
I don't want to use higher value of crystal nor PLL option.

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 04, 2015 4:32 pm     Reply with quote

Look at the .LST file. It will tell you.

First, you have this output_bit() code. It uses an int1 array (lcd_data).
To handle this int1 array, it branches off to a routine at 0060.
Quote:

.......... output_bit(data_pin,lcd_data[seg_loop]);
0198: MOVFF seg_loop,??65535
019C: CLRF @READBITA.P1+1
019E: MOVLW lcd_data
01A0: MOVWF @READBITA.P1
01A2: BRA 0060
01A4: BTFSC 01.0
01A6: BRA 01AC
01A8: BCF LATA.3
01AA: BRA 01AE
01AC: BSF LATA.3
01AE: BCF TRISA.3


Here is the bit cruncher routine at 0060:
Code:
0060:  MOVF   ??65535,W
0062:  ANDLW  07
0064:  MOVWF  @00
0066:  RRCF   ??65535,W
0068:  MOVWF  @01
006A:  RRCF   @01,F
006C:  RRCF   @01,F
006E:  MOVLW  1F
0070:  ANDWF  @01,F
0072:  MOVF   @01,W
0074:  ADDWF  @READBITA.P1,W
0076:  MOVWF  FSR0L
0078:  MOVLW  00
007A:  ADDWFC @READBITA.P1+1,W
007C:  MOVWF  FSR0H
007E:  MOVFF  INDF0,01
0082:  INCF   @00,F
0084:  BRA    0088
0086:  RRCF   @01,F
0088:  DECFSZ @00,F
008A:  BRA    0086
008C:  GOTO   01A4 (RETURN)


But what if I change the array declaration to int8, instead of int1 ?
Quote:
int8 lcd_data[176]

Then output_bit() reduces to this, only:
Code:
....... output_bit(data_pin,lcd_data[seg_loop]); 
0132:  CLRF   @03
0134:  MOVF   seg_loop,W
0136:  ADDLW  lcd_data
0138:  MOVWF  FSR0L
013A:  MOVLW  lcd_data+-4
013C:  ADDWFC @03,W
013E:  MOVWF  FSR0H
0140:  MOVF   INDF0,F
0142:  BNZ   0148
0144:  BCF    LATA.3
0146:  BRA    014A
0148:  BSF    LATA.3
014A:  BCF    TRISA.3

You could also make it a 'const' array, but that increases the run time
because it adds a little Table Read routine.

And these are just pure coding criticisms. There is also the question
of design. Your lcd_data[] array has all the bits set to 0 except for one
in the "15 position". Surely a better method of handling this single
exception could be invented, such as using an if() statement in the main
code. You don't need a huge array with only one little element set to 1.

This code below also needs to be cleaned up, but I didn't look at it:
Quote:
......... lcd_data[c-seg_loop2]=segs_7[segx[seg_loop]] & b;
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Wed Nov 04, 2015 10:35 pm     Reply with quote

Thanks PCM programmer for your reply

Quote:
You could also make it a 'const' array, but that increases the run time
because it adds a little Table Read routine.

I can't make it const because values will be changed in this array

Quote:
There is also the question
of design. Your lcd_data[] array has all the bits set to 0 except for one
in the "15 position"


I initially declared the array to 0. "1" at 15 position is just for checking if the dot point on the LCD dispaly is changing or not..

my actual data is in
Code:

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]=1;segx[21]=2;


for example i want to update my LCD position 0 with a value 9. I will update the segx[0]=9, like that all the segx[0 ->21] will be updated with the desired values.
then these segx array values will be replace by their 7-segment values in the following loop
Code:

c=175;   //Total nos of segments in an LCD.

      for(seg_loop=0;seg_loop<22;seg_loop++) //This loop place the 7-segment
      {                                      // values of each digit.
         b=0b10000000;
         for(seg_loop2=0;seg_loop2<=6;seg_loop2++)
         {
            lcd_data[c-seg_loop2]=segs_7[segx[seg_loop]] & b;
            rotate_right(&b,1);
         }
         c=c-8;
      }

in the above loop lcd_data[] array will be replaced by the updated values.

then it will send data to LCD Display in the following routine
Code:

 for(seg_loop=0;seg_loop<=175;seg_loop++)  //This loop update all  the LCD
      {                                         //having 175 segments.
         output_bit(data_pin,lcd_data[seg_loop]);
         output_high(clock_pin);
         output_low(clock_pin);
      }
      output_high(strobe_lcd);
      output_low(strobe_lcd);


need further assistance to solve it.

one more query. i can't find where is 0060 located in list file. how can i see it. what i am only seeing is BRA 0060
Code:

....................          output_bit(data_pin,lcd_data[seg_loop]);
01AC:  MOVFF  seg_loop,??65535
01B0:  CLRF   @READBITA.P1+1
01B2:  MOVLW  lcd_data
01B4:  MOVWF  @READBITA.P1
01B6:  BRA    0060
01B8:  BTFSC  01.0
01BA:  BRA    01C0
01BC:  BCF    LATA.3
01BE:  BRA    01C2
01C0:  BSF    LATA.3
01C2:  BCF    TRISA.3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 04, 2015 11:26 pm     Reply with quote

Quote:
i can't find where is 0060 located in list file. how can i see it
First, do a search. Press Ctrl-F and search for 0060, and hopefully you
will find it. If not, it's possible that in your compiler version (you didn't
post your version), that it's hidden code. In that case, edit the 18F252.h
file and comment out the #nolist statement near the top of the file. Then
re-compile and search the .LST file again for it again.


Quote:
need further assistance to solve it.

Did the changes that I already gave you, help to speed it up ?
I'll bet that they did. What is the measured speed increase ?
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Wed Nov 04, 2015 11:46 pm     Reply with quote

Yes PCM Programmer the program is speed up. Now it takes 12mS instead of 24mS. Thanks Very Happy

My Compiler version is 4.124
I did as you said


Code:

//////// Standard Header file for the PIC18F252 device ////////////////
#device PIC18F252
//!#nolist
//////// Program memory: 16384x16  Data RAM: 1536  Stack: 31
//////// I/O: 23   Analog Pins: 5
//////// Data EEPROM: 256
//////// C Scratch area: 00   ID Location: 200000
//////// Fuses: LP,XT,HS,RC,EC,EC_IO,H4,RC_IO,OSCSEN,NOOSCSEN,PUT,NOPUT
//////// Fuses: NOBROWNOUT,BROWNOUT,BORV45,BORV42,BORV27,BORV20,NOWDT,WDT
//////// Fuses: WDT1,WDT2,WDT4,WDT8,WDT16,WDT32,WDT64,WDT128,CCP2B3,CCP2C1
//////// Fuses: NOSTVREN,STVREN,NOLVP,LVP,DEBUG,NODEBUG,PROTECT,NOPROTECT
//////// Fuses: CPB,NOCPB,CPD,NOCPD,WRT,NOWRT,WRTC,NOWRTC,WRTB,NOWRTB,WRTD
//////// Fuses: NOWRTD,EBTR,NOEBTR,EBTRB,NOEBTRB
////////

But still not mentioning that location. Following is list file
Code:

CCS PCH C Compiler, Version 4.124              05-Nov-15 10:40

               Filename: C:\Users\Abdul Hayee\Desktop\bluesky lcd\bluesky_test1.lst

               ROM used: 476 bytes (1%)
                         Largest free fragment is 32292
               RAM used: 57 (4%) at main() level
                         60 (4%) worst case
               Stack:    1 locations

*
0000:  GOTO   main
.................... #include <18f252.h>
.................... //////// Standard Header file for the PIC18F252 device ////////////////
.................... #device PIC18F252
.................... #list
.................... 
.................... #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.
.................... 
.................... int1 lcd_data[176]={
....................     // dot, g, f, e, d, c, b, a
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 21 position, Dot value -> No Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 20 position, Dot value -> Effect
....................                     
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 19 position, Dot value -> Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 18 position, Dot value -> Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 17 position, Dot value -> Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 16 position, Dot value -> No Effect
....................                     
....................          1, 0, 0, 0, 0, 0, 0, 0,       // 15 position, Dot value -> No Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 14 position, Dot value -> Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 13 position, Dot value -> Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 12 position, Dot value -> Effect
....................                     
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 11 position, Dot value -> Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 10 position, Dot value -> No Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 09 position, Dot value -> No Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 08 position, Dot value -> No Effect
....................                     
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 07 position, Dot value -> No Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 06 position, Dot value -> Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 05 position, Dot value -> Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 04 position, Dot value -> Effect
....................                     
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 03 position, Dot value -> Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 02 position, Dot value -> No Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 01 position, Dot value -> No Effect
....................          0, 0, 0, 0, 0, 0, 0, 0,       // 00 position, Dot value -> No Effect
....................                    };
....................                     
.................... int1 out[8]={0,0,0,0,0,0,0,0};
.................... 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};
.................... 
....................                      // 0  ,  1 , 2  , 3  , 4  , 5  , 6  , 7  , 8  , 9  ,Blank,P //
.................... BYTE CONST segs_7[12]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6,0x00,0xce};
.................... 
.................... 
.................... int seg_loop,seg_loop2,c,b;
.................... 
.................... void main()
.................... {
0090:  CLRF   TBLPTRU
0092:  BCF    RCON.IPEN
0094:  CLRF   FSR0H
0096:  CLRF   FSR0L
0098:  BSF    ADCON1.PCFG0
009A:  BSF    ADCON1.PCFG1
009C:  BSF    ADCON1.PCFG2
009E:  BCF    ADCON1.PCFG3
00A0:  CLRF   lcd_data
00A2:  CLRF   lcd_data+1
00A4:  CLRF   lcd_data+2
00A6:  CLRF   lcd_data+3
00A8:  CLRF   lcd_data+4
00AA:  CLRF   lcd_data+5
00AC:  MOVLW  01
00AE:  MOVWF  lcd_data+6
00B0:  CLRF   lcd_data+7
00B2:  CLRF   lcd_data+8
00B4:  CLRF   lcd_data+9
00B6:  CLRF   lcd_data+10
00B8:  CLRF   lcd_data+11
00BA:  CLRF   lcd_data+12
00BC:  CLRF   lcd_data+13
00BE:  CLRF   lcd_data+14
00C0:  CLRF   lcd_data+15
00C2:  CLRF   lcd_data+16
00C4:  CLRF   lcd_data+17
00C6:  CLRF   lcd_data+18
00C8:  CLRF   lcd_data+19
00CA:  CLRF   lcd_data+20
00CC:  CLRF   lcd_data+21
00CE:  CLRF   out+1
00D0:  CLRF   out
00D2:  CLRF   segx
00D4:  CLRF   segx+1
00D6:  CLRF   segx+2
00D8:  CLRF   segx+3
00DA:  CLRF   segx+4
00DC:  CLRF   segx+5
00DE:  CLRF   segx+6
00E0:  CLRF   segx+7
00E2:  CLRF   segx+8
00E4:  CLRF   segx+9
00E6:  CLRF   segx+10
00E8:  CLRF   segx+11
00EA:  CLRF   segx+12
00EC:  CLRF   segx+13
00EE:  CLRF   segx+14
00F0:  CLRF   segx+15
00F2:  CLRF   segx+16
00F4:  CLRF   segx+17
00F6:  CLRF   segx+18
00F8:  CLRF   segx+19
00FA:  CLRF   segx+20
00FC:  CLRF   segx+21
....................    while(TRUE)
....................    {
....................       output_toggle(PIN_C0);
00FE:  BCF    TRISC.0
0100:  BTG    LATC.0
....................       
....................       //Data to be shown on LCD.
....................       segx[0]=9;segx[1]=8;segx[2]=7;segx[3]=6;segx[4]=5;segx[5]=4;
0102:  MOVLW  09
0104:  MOVWF  segx
0106:  MOVLW  08
0108:  MOVWF  segx+1
010A:  MOVLW  07
010C:  MOVWF  segx+2
010E:  MOVLW  06
0110:  MOVWF  segx+3
0112:  MOVLW  05
0114:  MOVWF  segx+4
0116:  MOVLW  04
0118:  MOVWF  segx+5
....................       segx[6]=3;segx[7]=2;segx[8]=1;segx[9]=0;segx[10]=1;segx[11]=2;
011A:  MOVLW  03
011C:  MOVWF  segx+6
011E:  MOVLW  02
0120:  MOVWF  segx+7
0122:  MOVLW  01
0124:  MOVWF  segx+8
0126:  CLRF   segx+9
0128:  MOVWF  segx+10
012A:  MOVLW  02
012C:  MOVWF  segx+11
....................       segx[12]=3;segx[13]=4;segx[14]=5;segx[15]=6;segx[16]=7;segx[17]=8;
012E:  MOVLW  03
0130:  MOVWF  segx+12
0132:  MOVLW  04
0134:  MOVWF  segx+13
0136:  MOVLW  05
0138:  MOVWF  segx+14
013A:  MOVLW  06
013C:  MOVWF  segx+15
013E:  MOVLW  07
0140:  MOVWF  segx+16
0142:  MOVLW  08
0144:  MOVWF  segx+17
....................       segx[18]=9;segx[19]=0;segx[20]=1;segx[21]=2;
0146:  MOVLW  09
0148:  MOVWF  segx+18
014A:  CLRF   segx+19
014C:  MOVLW  01
014E:  MOVWF  segx+20
0150:  MOVLW  02
0152:  MOVWF  segx+21
.................... 
....................       c=175;   //Total nos of segments in an LCD.
0154:  MOVLW  AF
0156:  MOVWF  c
.................... 
....................       for(seg_loop=0;seg_loop<22;seg_loop++) //This loop place the 7-segment 
0158:  CLRF   seg_loop
015A:  MOVF   seg_loop,W
015C:  SUBLW  15
015E:  BNC   01A4
....................       {                                      // values of each digit.
....................          b=0b10000000;
0160:  MOVLW  80
0162:  MOVWF  b
....................          for(seg_loop2=0;seg_loop2<=6;seg_loop2++)
0164:  CLRF   seg_loop2
0166:  MOVF   seg_loop2,W
0168:  SUBLW  06
016A:  BNC   019C
....................          {
....................             lcd_data[c-seg_loop2]=segs_7[segx[seg_loop]] & b;
016C:  MOVF   seg_loop2,W
016E:  SUBWF  c,W
0170:  MOVWF  @@37
0172:  CLRF   @03
0174:  MOVF   seg_loop,W
0176:  ADDLW  segx
0178:  MOVWF  FSR0L
017A:  MOVLW  segx+-27
017C:  ADDWFC @03,W
017E:  MOVWF  FSR0H
0180:  CLRF   @03
0182:  MOVF   INDF0,W
0184:  RCALL  0004
0186:  ANDWF  b,W
0188:  MOVFF  @@37,??65535
018C:  MOVWF  @WRITEBITA.P1
018E:  CLRF   @WRITEBITA.P2+1
0190:  MOVLW  lcd_data
0192:  MOVWF  @WRITEBITA.P2
0194:  BRA    0020
....................             rotate_right(&b,1);
0196:  RRNCF  b,F
....................          }
0198:  INCF   seg_loop2,F
019A:  BRA    0166
....................          c=c-8;
019C:  MOVLW  08
019E:  SUBWF  c,F
....................       }
01A0:  INCF   seg_loop,F
01A2:  BRA    015A
....................       
....................       for(seg_loop=0;seg_loop<=175;seg_loop++)  //This loop update all the LCD
01A4:  CLRF   seg_loop
01A6:  MOVF   seg_loop,W
01A8:  SUBLW  AF
01AA:  BNC   01D0
....................       {                                         //having 175 segments.
....................          output_bit(data_pin,lcd_data[seg_loop]);
01AC:  MOVFF  seg_loop,??65535
01B0:  CLRF   @READBITA.P1+1
01B2:  MOVLW  lcd_data
01B4:  MOVWF  @READBITA.P1
01B6:  BRA    0060
01B8:  BTFSC  01.0
01BA:  BRA    01C0
01BC:  BCF    LATA.3
01BE:  BRA    01C2
01C0:  BSF    LATA.3
01C2:  BCF    TRISA.3
....................          output_high(clock_pin);
01C4:  BCF    TRISA.2
01C6:  BSF    LATA.2
....................          output_low(clock_pin);
01C8:  BCF    TRISA.2
01CA:  BCF    LATA.2
....................       }
01CC:  INCF   seg_loop,F
01CE:  BRA    01A6
....................       output_high(strobe_lcd);
01D0:  BCF    TRISA.1
01D2:  BSF    LATA.1
....................       output_low(strobe_lcd);
01D4:  BCF    TRISA.1
01D6:  BCF    LATA.1
....................    }
01D8:  BRA    00FE
.................... }
01DA:  SLEEP

Configuration Fuses:
   Word  1: 2200   HS NOOSCSEN
   Word  2: 0E0E   PUT BROWNOUT BORV20 NOWDT WDT128
   Word  3: 0100   CCP2C1
   Word  4: 0081   STVREN NOLVP NODEBUG
   Word  5: C00F   NOPROTECT NOCPB NOCPD
   Word  6: E00F   NOWRT NOWRTC NOWRTB NOWRTD
   Word  7: 400F   NOEBTR NOEBTRB
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 05, 2015 5:46 pm     Reply with quote

hayee wrote:

i can't find where is 0060 located in list file. how can i see it ?
But still not mentioning that location.

Commenting out the #nolist statement worked for me. I installed
compiler vs. 4.124 and commented out #nolist in the 18F252.h file,
as shown in bold below:
Quote:
//////// Standard Header file for the PIC18F252 device ////////////////
#device PIC18F252
//#nolist
//////// Program memory: 16384x16 Data RAM: 1536 Stack: 31
//////// I/O: 23 Analog Pins: 5
//////// Data EEPROM: 256
//////// C Scratch area: 00 ID Location: 200000
//////// Fuses: LP,XT,HS,RC,EC,EC_IO,H4,RC_IO,OSCSEN,NOOSCSEN,PUT,NOPUT

Then I re-compiled and looked at the .LST file, and there's the code
right at address 0060, as shown in bold below:
Quote:

0000: GOTO main
.................... #include <18f252.h>
.................... //////// Standard Header file for the PIC18F252 device ////////////////
.................... #device PIC18F252
0004: CLRF TBLPTRH
0006: ADDLW 14
0008: MOVWF TBLPTRL
000A: MOVLW 00
000C: ADDWFC TBLPTRH,F
000E: TBLRD*+
0010: MOVF TABLAT,W
0012: RETURN 0
0014: DATA FC,60
0016: DATA DA,F2
0018: DATA 66,B6
001A: DATA BE,E0
001C: DATA FE,F6
001E: DATA 00,CE
0020: MOVF ??65535,W
0022: ANDLW 07
0024: MOVWF @00
0026: RRCF ??65535,W
0028: MOVWF @01
002A: RRCF @01,F
002C: RRCF @01,F
002E: MOVLW 1F
0030: ANDWF @01,F
0032: MOVF @01,W
0034: ADDWF @WRITEBITA.P2,W
0036: MOVWF FSR0L
0038: MOVLW 00
003A: ADDWFC @WRITEBITA.P2+1,W
003C: MOVWF FSR0H
003E: CLRF @01
0040: INCF @01,F
0042: INCF @00,F
0044: BRA 0048
0046: RLCF @01,F
0048: DECFSZ @00,F
004A: BRA 0046
004C: MOVF @WRITEBITA.P1,F
004E: BZ 0056
0050: MOVF @01,W
0052: IORWF INDF0,F
0054: BRA 005C
0056: COMF @01,F
0058: MOVF @01,W
005A: ANDWF INDF0,F
005C: GOTO 0196 (RETURN)
0060: MOVF ??65535,W // Start of data fetch routine for int1 array
0062: ANDLW 07
0064: MOVWF @00
0066: RRCF ??65535,W
0068: MOVWF @01
006A: RRCF @01,F
006C: RRCF @01,F
006E: MOVLW 1F
0070: ANDWF @01,F
0072: MOVF @01,W
0074: ADDWF @READBITA.P1,W
0076: MOVWF FSR0L
0078: MOVLW 00
007A: ADDWFC @READBITA.P1+1,W
007C: MOVWF FSR0H
007E: MOVFF INDF0,01
0082: INCF @00,F
0084: BRA 0088
0086: RRCF @01,F
0088: DECFSZ @00,F
008A: BRA 0086
008C: GOTO 01B8 (RETURN)

The routine starts at 0060 and continues to 008C, where it returns to the caller.
Eugeneo



Joined: 30 Aug 2005
Posts: 155
Location: Calgary, AB

View user's profile Send private message

PostPosted: Sun Nov 08, 2015 3:07 pm     Reply with quote

Something like this would be faster.


Code:


BYTE CONST segs_7[12]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6,0x00,0xce};

#define latch_seg output_high(clock_pin); output_low(clock_pin)

send_seg(int8 bit_value)
{
output_bit(bit_test (bit_value, 0);
latch_seg;
output_bit(bit_test (bit_value, 1);
latch_seg;
output_bit(bit_test (bit_value, 2);
latch_seg;
output_bit(bit_test (bit_value, 3);
latch_seg;
output_bit(bit_test (bit_value, 4);
latch_seg;
output_bit(bit_test (bit_value, 5);
latch_seg;
output_bit(bit_test (bit_value, 6);
latch_seg;
output_bit(bit_test (bit_value, 7);
latch_seg;
}



for(seg_loop=21; seg_loop > 0; seg_loop--)
    {
    send_seg(segs_7[segx[seg_loop]]);
    output_high(strobe_lcd);
    output_low(strobe_lcd);
    }
   

Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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