Const truncated

General discussion on mikroC.
Post Reply
Author
Message
flourette
Posts: 5
Joined: 17 May 2005 11:49

Const truncated

#1 Post by flourette » 17 May 2005 11:50

Hello
how to solve the problem of constant truncated? because I use much function LCD_OUT and I have half of the lines which are posted.
Thank you in advance.

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

Re: Const truncated

#2 Post by rajkovic » 17 May 2005 19:05

flourette wrote:Hello
how to solve the problem of constant truncated? because I use much function LCD_OUT and I have half of the lines which are posted.
Thank you in advance.
Please post code or bit of it that causes errors

Aoday
Posts: 86
Joined: 07 Mar 2005 13:45

#3 Post by Aoday » 18 May 2005 08:38

Hi I have the same error and it make the lcd not working the code is as below

Code: Select all

char txt[15],*txt1,*txt2;
unsigned long w3,m3;
unsigned w1,w2,volt,temp_VOL,curr,temp_cur,cph,ph,cnt,i,j,re,po,re1,po1,re2,po2,WAT,unit;
unsigned short fl,cou,m1,m2,m4,vp,cp1,inb,scanb,sc,os,OS1,tempP,whh,whl,dis;

//-------------- Copies a string from <*from> to <*to> arrray
char *AddStrings(char *startstr, char *addstr) {
  unsigned short int a,i;
  for(a = Length(startstr),i=0; addstr[i] != 0; i ++) {
    startstr[a + i] = addstr[i];
  }
  startstr[a+i] = 0;
  return startstr;
}
char *Trim(char *Tstr) {
  unsigned short int a=0,i=0;
  while(Tstr[a] == 0x20) {
   a++;
       };
while (Tstr[a]!=0){
  Tstr[i]=Tstr[a];
  i++;
  a++;
};
  Tstr[i] = 0;
  return Tstr;
}

char * strcpy(char *to,  char *from) {
	char *cp;
  cp = to;
	while(*cp++ = *from++) ;
	return to;
}//~
void Disp() {
    re=(unsigned)(((float) w3/72.)*10);
    LCD8_Cmd(LCD_clear);
    po=re/10;
    wordtostr(po,txt);
    trim(txt);
    LCD8_Out(1,1,"Total=");
    LCD8_Out(1,10,txt);
    LCD8_Out_CP(".");
    po=re%10;
    wordtostr(po,txt);
    trim(txt);
    LCD8_Out_CP(txt);
    LCD8_Out_CP(" KWh");
    re=(unsigned)(((float) unit/72.)*10);
    po=re/10;
    LCD8_Out(2,1,"Remain=");
    wordtostr(po,txt);
    trim(txt);
    LCD8_Out(2,10,txt);
    LCD8_Out_CP(".");
    po=re%10;
    wordtostr(po,txt);
    trim(txt);
    LCD8_Out_CP(txt);
    LCD8_Out_CP(" KWh");
}//~
void Disp1() {
     LCD8_Cmd(LCD_clear);
     Lcd8_Chr(1,1,0X57);
     Lcd8_Chr(1,2,0X3D);
     wordtostr(wat,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     Lcd8_Chr(1,1,0X20);
     Lcd8_Chr(1,1,0X57);
     LCD8_Out(1,12,"Ph=");
     po=ph/1000;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     LCD8_Out_CP(".");
     po=(ph/100)%10;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     po=(ph/10)%10;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     po=ph%10;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);
}//~
void Init_Main() {
  T1CON = 0x31;
  PIR1.TMR1IF = 0;            // clear TMR1IF
  ADCON1      =   0;       // all porta pins as analog, VDD as Vref
  TRISA       =   0xFF;       // all porta pins as inputs
  TRISB       =   0xF0;
  TRISC       =   0x30;
  TRISD       =   0;
  scanb       =   0x0e;
  os=0;
  fl=0;
  cou=0;
  i=0;
  j=0;
  cnt = 0;             // Initialize cnt
  TMR1H=0x6D;
  TMR1L=0x83;
   dis=0;
  LCD8_Config(&PORTc,&PORTD,0,2,1,7,6,5,4,3,2,1,0);
//  LCD8_Init(&portb);
  LCD8_Cmd(LCD_CURSOR_OFF);  // Turn cursor off\
  LCD8_Cmd(LCD_CLEAR);
  USART_init(9600);
  LCD8_Out(1,1,"Ready........");
  m1=EEprom_read(0);
  m2=EEprom_read(1);
  m3=(m1*0x100)+m2;
  m4=EEprom_read(4);
//  m4=EEprom_read(5);
  m3=(m3*0x100)+m4;
  m4=EEprom_read(5);
  w3=(m3*0x100)+m4;
  m1=EEprom_read(2);
  m2=EEprom_read(3);
  w2=(m1*0x100)+m2;
  m1=EEprom_read(6);
  unit=m1*0x100;
  m1=EEprom_read(7);
  unit=unit+m1;
}//~

void Process_SC() {
   if ((inb != 0xf0) && (os == 0))
   {
   os=1;
   os1=scanb;
   sc=(scanb | inb);
   dis=10;
   if (fl==1)
   {
   cou++;
   if (cou==20)
     {
     unit+=720;
     fl=0;
     cou=0;
     dis=0;
//          LCD8_Cmd(LCD8_clear);
//          LCD8_Out(2,1,"Thanks.........");
     };
  };
/*          LCD8_Cmd(LCD8_clear);
     wordtostr(sc,txt);
     LCD8_Out(1,1,txt);*/
      if (SC==123)
       {
          LCD8_Cmd(LCD_clear);
          LCD8_Out(1,1,"Enter The Number:");
          LCD8_Out(2,1,"->");
          fl=1;
          cou=0;
       } ;
   if (sc==125)
   {
     LCD8_Cmd(LCD_clear);
     LCD8_Out(1,1,"V=");
     po=volt/10;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     LCD8_Out_CP(".");
     po=volt%10;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     LCD8_Out_CP(" V");

     LCD8_Out(1,12,"A=");
     po=curr/1000;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     LCD8_Out_CP(".");
     po=(curr/100)%10;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     po=(curr/10)%10;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     po=curr%10;
     wordtostr(po,txt);
    trim(txt);
     LCD8_Out_CP(txt);

   };
      if (sc==119) {
      disp1();
      };
      if (sc==126) {
      LCD8_Cmd(LCD_clear);
      LCD8_Out(1,1,"Counter No.:");
      LCD8_Out(2,1,"      ");
      for (i=10;i<18;i++)
      {
        po=EEprom_read(i);
        LCD8_Chr_CP(po);
      }
      };
   if (sc==235) Lcd8_Chr_CP(0x31);
   if (sc==219) Lcd8_Chr_CP(0x32);
   if (sc==187) Lcd8_Chr_CP(0x33);
   if (sc==237) Lcd8_Chr_CP(0x34);
   if (sc==221) Lcd8_Chr_CP(0x35);
   if (sc==189) Lcd8_Chr_CP(0x36);
   if (sc==238) Lcd8_Chr_CP(0x37);
   if (sc==222) Lcd8_Chr_CP(0x38);
   if (sc==190) Lcd8_Chr_CP(0x39);
   if (sc==215) Lcd8_Chr_CP(0x30);
   if (sc==231) Lcd8_Chr_CP(0x2a);
   if (sc==183) Lcd8_Chr_CP(0x23);
//   if (sc==119) LCD8_Out_CP("c1");
//   if (sc==183) LCD8_Out_CP("c2");
//   if (sc==215) LCD8_Out_CP("c3");
//   if (sc==231) LCD8_Out_CP("c4");
   }
}//~



void main() {
  Init_Main();
  do {
    T1CON = 0x31;
    if (PIR1.TMR1IF==1) {
     cnt++;
     PIR1.TMR1IF=0;
     TMR1H=0x6D;
     TMR1L=0x83;
    }
    if (cnt >= 10) {
    cnt = 0;        // Reset cnt
      cph=0;
      ph=0;
      for(i=1;i<1000;i++)
      {
        tempP=PORTC;
        vp=tempP.f4;
        cp1=tempP.f5;
        if ((vp==1) && (cp1==0)) cph++;
      }
      ph=(cph * 360)/ 1000;
//      ph=1000;
      ph=cosE3(ph);
      temp_cur = ADC_read(1) & 0X3ff;  // read conversion result and push
      if (temp_cur<=700)
      {
      curr=(8 * temp_cur)+1018;
      if (temp_cur<=10) curr=0;
      }
      else
      {
      temp_cur = ADC_read(2) & 0x3ff;  // read conversion result and push
      curr=(8 * temp_cur)+781;
      }
      temp_VOL = ADC_read(0) & 0x3ff;  // read conversion result and push
      volt=3*temp_VOL;
      re1=curr/1000;
      po1=curr%1000;
      re2=ph/1000;
      po2=ph%1000;
      re=(re1*re2*1000)+((re1*po2)+(re2*po1));
      po=(((po1/10)*(po2/10))/10);
      re=re+po;
      wat=((volt/10)*(re/1000))+((volt/10)*((re%1000)/10)/100);
      w2=w2+wat;
      if (w2>50000) unit--;
      if (w2>50000) w2-=50000;
      if (w2>50000) w3++;
    whh=w3;
    EEprom_write(5,whh);
    whh=w3/0x100;
    EEprom_write(4,whh);
    whh=w3/0x10000;
    EEprom_write(1,whh);
    whh=w3/0x1000000;
    EEprom_write(0,whh);
    whh=w2/0x100;
    whl=w2%0x100;
    EEprom_write(2,whh);
    EEprom_write(3,whl);
    whh=unit;
    EEprom_write(7,whh);
    whh=unit/0x100;
    EEprom_write(6,whh);
    w1=w3;
   if(dis<=0)
   {
   disp();
   }
   else dis--;
//       ??CE C??ICI ???I ??Cinterupt
    }
   scanb= scanb << 1;
   scanb = ((scanb | 1) & (0x0f));
   if (scanb == 0x0f) scanb=0x0e;
   PORTB=scanb;
   inb=PORTB & 0xf0;
   if ((inb==0xf0) && (scanb==os1)) {
   os=0;
   }
   Process_SC();
   delay_ms(1);
  } while(1);
}//~!

pizon
mikroElektronika team
Posts: 823
Joined: 11 Oct 2004 08:53

#4 Post by pizon » 18 May 2005 10:30

This is how it should be done:

Code: Select all

const char cca_total[]          = "Total=";
const char cca_kwh[]            = " KWh";
const char cca_remain[]         = "Remain=";
const char cca_ph[]             = "Ph=";
const char cca_ready[]          = "Ready........";
const char cca_enterthenumber[] = "Enter the Number:";
const char cca_arrowright[]     = "->";
const char cca_vequals[]        = "V=";
const char cca_v[]              = " V";
const char cca_aequals[]        = "A=";
const char cca_counterno[]      = "Counter No.:";
const char cca_spaces[]         = "      ";


char txt[15],txt_msg[15],*txt1,*txt2;
unsigned long w3,m3;
unsigned w1,w2,volt,temp_VOL,curr,temp_cur,cph,ph,cnt,i,j,re,po,re1,po1,re2,po2,WAT,unit;
unsigned short fl,cou,m1,m2,m4,vp,cp1,inb,scanb,sc,os,OS1,tempP,whh,whl,dis;


char *AddStrings(char *startstr, char *addstr) {
  unsigned short int a,i;
  for(a = Length(startstr),i=0; addstr[i] != 0; i ++) {
    startstr[a + i] = addstr[i];
  }
  startstr[a+i] = 0;
  return startstr;
}//~

//-------------- Copies constant string (in ROM) to 'normal' string (in RAM)
void strcp_c(char *str1, const char *cstr2) {
  unsigned short i = 0;

  do {
    str1[i] = cstr2[i];
  } while (str1[i++]);
}//~

char *Trim(char *Tstr) {
  unsigned short int a=0,i=0;
  while(Tstr[a] == 0x20) {
   a++;
       };
while (Tstr[a]!=0){
  Tstr[i]=Tstr[a];
  i++;
  a++;
};
  Tstr[i] = 0;
  return Tstr;
}

char * strcpy(char *to,  char *from) {
   char *cp;
  cp = to;
   while(*cp++ = *from++) ;
   return to;
}//~

void Disp() {
    re=(unsigned)(((float) w3/72.)*10);
    LCD8_Cmd(LCD_clear);
    po=re/10;
    wordtostr(po,txt);
    trim(txt);
//---    LCD8_Out(1,1,"Total=");
    strcp_c(txt_msg, cca_total);
    LCD8_Out(1,1,txt_msg);
//^^^
    LCD8_Out(1,10,txt);
//---    LCD8_Out_CP(".");
    Lcd8_Chr_CP('.');
//^^^
    po=re%10;
    WordToStr(po,txt);
    trim(txt);
    Lcd8_Out_CP(txt);
//---    Lcd8_Out_CP(" KWh");
    strcp_c(txt_msg, cca_kwh);
    Lcd8_Out_CP(txt_msg);
//^^^
    re=(unsigned)(((float) unit/72.)*10);
    po=re/10;
//---    Lcd8_Out(2,1,"Remain=");
    strcp_c(txt_msg, cca_remain);
    Lcd8_Out(2,1,txt_msg);
//^^^
    WordToStr(po,txt);
    trim(txt);
    Lcd8_Out(2,10,txt);
//---    LCD8_Out_CP(".");
    Lcd8_Chr_CP('.');
//^^^
    po=re%10;
    WordToStr(po,txt);
    trim(txt);
    LCD8_Out_CP(txt);
//---    LCD8_Out_CP(" KWh");
    strcp_c(txt_msg, cca_kwh);
    Lcd8_Out_CP(txt_msg);
//^^^
}//~

void Disp1() {
     LCD8_Cmd(LCD_clear);
     Lcd8_Chr(1,1,0X57);
     Lcd8_Chr(1,2,0X3D);
     wordtostr(wat,txt);
    trim(txt);
     LCD8_Out_CP(txt);
     Lcd8_Chr(1,1,0X20);
     Lcd8_Chr(1,1,0X57);
//---     LCD8_Out(1,12,"Ph=");
     strcp_c(txt_msg, cca_ph);
     Lcd8_Out(1,12,txt_msg);
//^^^
     po=ph/1000;
     WordToStr(po,txt);
    trim(txt);
     Lcd8_Out_CP(txt);
//---     LCD8_Out_CP(".");
     Lcd8_Chr_CP('.');
//^^^
     po=(ph/100)%10;
     WordToStr(po,txt);
     trim(txt);
     Lcd8_Out_CP(txt);
     po=(ph/10)%10;
     WordToStr(po,txt);
     trim(txt);
     Lcd8_Out_CP(txt);
     po=ph%10;
     WordToStr(po,txt);
    trim(txt);
     Lcd8_Out_CP(txt);
}//~

void Init_Main() {
  T1CON = 0x31;
  PIR1.TMR1IF = 0;            // clear TMR1IF
  ADCON1      =   0;       // all porta pins as analog, VDD as Vref
  TRISA       =   0xFF;       // all porta pins as inputs
  TRISB       =   0xF0;
  TRISC       =   0x30;
  TRISD       =   0;
  scanb       =   0x0e;
  os=0;
  fl=0;
  cou=0;
  i=0;
  j=0;
  cnt = 0;             // Initialize cnt
  TMR1H=0x6D;
  TMR1L=0x83;
   dis=0;
  LCD8_Config(&PORTc,&PORTD,0,2,1,7,6,5,4,3,2,1,0);
//  LCD8_Init(&portb);
  LCD8_Cmd(LCD_CURSOR_OFF);  // Turn cursor off\
  LCD8_Cmd(LCD_CLEAR);
  USART_init(9600);
//---  LCD8_Out(1,1,"Ready........");
  strcp_c(txt_msg, cca_ready);
  Lcd8_Out(1,1,txt_msg);
//^^^
  m1=EEprom_read(0);
  m2=EEprom_read(1);
  m3=(m1*0x100)+m2;
  m4=EEprom_read(4);
//  m4=EEprom_read(5);
  m3=(m3*0x100)+m4;
  m4=EEprom_read(5);
  w3=(m3*0x100)+m4;
  m1=EEprom_read(2);
  m2=EEprom_read(3);
  w2=(m1*0x100)+m2;
  m1=EEprom_read(6);
  unit=m1*0x100;
  m1=EEprom_read(7);
  unit=unit+m1;
}//~

void Process_SC() {
   if ((inb != 0xf0) && (os == 0))
   {
   os=1;
   os1=scanb;
   sc=(scanb | inb);
   dis=10;
   if (fl==1)
   {
   cou++;
   if (cou==20)
     {
     unit+=720;
     fl=0;
     cou=0;
     dis=0;
//          LCD8_Cmd(LCD8_clear);
//          LCD8_Out(2,1,"Thanks.........");
     };
  };
/*          LCD8_Cmd(LCD8_clear);
     wordtostr(sc,txt);
     LCD8_Out(1,1,txt);*/
      if (SC==123)
       {
          LCD8_Cmd(LCD_clear);
//---          Lcd8_Out(1,1,"Enter The Number:");
          strcp_c(txt_msg, cca_enterthenumber);
          Lcd8_Out(1,1,txt_msg);
//^^^
//---          Lcd8_Out(2,1,"->");
          strcp_c(txt_msg, cca_arrowright);
          Lcd8_Out(2,1,txt_msg);
//^^^
          fl=1;
          cou=0;
       } ;
   if (sc==125)
   {
     LCD8_Cmd(LCD_clear);
//---     Lcd8_Out(1,1,"V=");
     strcp_c(txt_msg, cca_vequals);
     Lcd8_Out(1,1,txt_msg);
//^^^
     po=volt/10;
     WordToStr(po,txt);
    trim(txt);
     Lcd8_Out_CP(txt);
//---     Lcd8_Out_CP(".");
     Lcd8_Chr_CP('.');
//^^^
     po=volt%10;
     WordToStr(po,txt);
    trim(txt);
     Lcd8_Out_CP(txt);
//---     Lcd8_Out_CP(" V");
     strcp_c(txt_msg, cca_v);
     Lcd8_Out_CP(txt_msg);
//^^^
//---     Lcd8_Out(1,12,"A=");
     strcp_c(txt_msg, cca_aequals);
     Lcd8_Out(1,12,txt_msg);
//^^^
     po=curr/1000;
     WordToStr(po,txt);
    trim(txt);
     Lcd8_Out_CP(txt);
//---     LCD8_Out_CP(".");
     Lcd8_Chr_CP('.');
//^^^
     po=(curr/100)%10;
     WordToStr(po,txt);
    trim(txt);
     Lcd8_Out_CP(txt);
     po=(curr/10)%10;
     WordToStr(po,txt);
    trim(txt);
     Lcd8_Out_CP(txt);
     po=curr%10;
     WordToStr(po,txt);
    trim(txt);
     Lcd8_Out_CP(txt);

   };
      if (sc==119) {
      disp1();
      };
      if (sc==126) {
      LCD8_Cmd(LCD_clear);
//---      LCD8_Out(1,1,"Counter No.:");
      strcp_c(txt_msg, cca_counterno);
      Lcd8_Out(1,1,txt_msg);
//^^^
//---      LCD8_Out(2,1,"      ");
      strcp_c(txt_msg, cca_spaces);
      Lcd8_Out(2,1,txt_msg);
//^^^
      for (i=10;i<18;i++)
      {
        po=EEprom_read(i);
        LCD8_Chr_CP(po);
      }
      };
   if (sc==235) Lcd8_Chr_CP(0x31);
   if (sc==219) Lcd8_Chr_CP(0x32);
   if (sc==187) Lcd8_Chr_CP(0x33);
   if (sc==237) Lcd8_Chr_CP(0x34);
   if (sc==221) Lcd8_Chr_CP(0x35);
   if (sc==189) Lcd8_Chr_CP(0x36);
   if (sc==238) Lcd8_Chr_CP(0x37);
   if (sc==222) Lcd8_Chr_CP(0x38);
   if (sc==190) Lcd8_Chr_CP(0x39);
   if (sc==215) Lcd8_Chr_CP(0x30);
   if (sc==231) Lcd8_Chr_CP(0x2a);
   if (sc==183) Lcd8_Chr_CP(0x23);
//   if (sc==119) LCD8_Out_CP("c1");
//   if (sc==183) LCD8_Out_CP("c2");
//   if (sc==215) LCD8_Out_CP("c3");
//   if (sc==231) LCD8_Out_CP("c4");
   }
}//~



void main() {
  Init_Main();
  do {
    T1CON = 0x31;
    if (PIR1.TMR1IF==1) {
     cnt++;
     PIR1.TMR1IF=0;
     TMR1H=0x6D;
     TMR1L=0x83;
    }
    if (cnt >= 10) {
    cnt = 0;        // Reset cnt
      cph=0;
      ph=0;
      for(i=1;i<1000;i++)
      {
        tempP=PORTC;
        vp=tempP.f4;
        cp1=tempP.f5;
        if ((vp==1) && (cp1==0)) cph++;
      }
      ph=(cph * 360)/ 1000;
//      ph=1000;
      ph=cosE3(ph);
      temp_cur = ADC_read(1) & 0X3ff;  // read conversion result and push
      if (temp_cur<=700)
      {
      curr=(8 * temp_cur)+1018;
      if (temp_cur<=10) curr=0;
      }
      else
      {
      temp_cur = ADC_read(2) & 0x3ff;  // read conversion result and push
      curr=(8 * temp_cur)+781;
      }
      temp_VOL = ADC_read(0) & 0x3ff;  // read conversion result and push
      volt=3*temp_VOL;
      re1=curr/1000;
      po1=curr%1000;
      re2=ph/1000;
      po2=ph%1000;
      re=(re1*re2*1000)+((re1*po2)+(re2*po1));
      po=(((po1/10)*(po2/10))/10);
      re=re+po;
      wat=((volt/10)*(re/1000))+((volt/10)*((re%1000)/10)/100);
      w2=w2+wat;
      if (w2>50000) unit--;
      if (w2>50000) w2-=50000;
      if (w2>50000) w3++;
    whh=w3;
    EEprom_write(5,whh);
    whh=w3/0x100;
    EEprom_write(4,whh);
    whh=w3/0x10000;
    EEprom_write(1,whh);
    whh=w3/0x1000000;
    EEprom_write(0,whh);
    whh=w2/0x100;
    whl=w2%0x100;
    EEprom_write(2,whh);
    EEprom_write(3,whl);
    whh=unit;
    EEprom_write(7,whh);
    whh=unit/0x100;
    EEprom_write(6,whh);
    w1=w3;
   if(dis<=0)
   {
   disp();
   }
   else dis--;
//       ??CE C??ICI ???I ??Cinterupt
    }
   scanb= scanb << 1;
   scanb = ((scanb | 1) & (0x0f));
   if (scanb == 0x0f) scanb=0x0e;
   PORTB=scanb;
   inb=PORTB & 0xf0;
   if ((inb==0xf0) && (scanb==os1)) {
   os=0;
   }
   Process_SC();
   delay_ms(1);
  } while(1);
}//~!
Whenever you do something like

Code: Select all

LCD8_Out(1,1,"Counter No.:");
, the string is being stored in a background string array in RAM. Each time you do it, new string array is formed and new piece of RAM occupied. Now, since pointers (and therefore arrays) on PIC16 can work only in the first two banks (0 and 1), you can see how bad it can get. The solution is to have one string in RAM that is filled with various messages on-demand, and then sent to the LCD. As you can see, strings are now being kept in ROM (by being declared as const). You can also take a look at the ethernet example, to see how html pages are stored.
The message 'Const truncated: lstrXXX_1' means that the compiler hasn't been able to place the temporary string lstrXXX_ in the first two banks in RAM.
pizon

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#5 Post by gambrose » 27 May 2005 10:57

Yesterday i was struggling with these memory problems and passing strings to the LCD routines. not exactly the same i think the extra memory was causing banking problems or something.

But my point is why do we have to write crazy string loading routines when the LCD routines don't really need variables anyway.

If you change the LCD routines to accept a const you don't get these memory problems.

BTW did you guys very get round to changing the delay on LCD_Cmd? because while your there there. :wink:
Graham Ambrose

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#6 Post by zristic » 27 May 2005 11:47

gambrose wrote:BTW did you guys very get round to changing the delay on LCD_Cmd?
We tried to shorten the delays, but not all samples of LCDs worked. Sorry, but that's the way it is. You have to wait 5.5ms for each command.

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#7 Post by gambrose » 27 May 2005 11:53

Oh well, you guys odiously have a much larger selection of LCDs than me.

Would it be possible to do the const string thing though?
Graham Ambrose

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#8 Post by zristic » 27 May 2005 12:02

gambrose wrote:Oh well, you guys odiously have a much larger selection of LCDs than me.
Two crates of various displays (even 1x32). :lol:
Would it be possible to do the const string thing though?
Of course, might be posted as a project. Note there will be a limited use of it, since you cannot write values of numbers obtained by WordToStr, ByteToStr, as in AdcOnLcd example. You will be able to write const texts only.

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#9 Post by gambrose » 27 May 2005 17:14

I think that maybe an 'overload' like LCD_Out_Const() and LCD_Out_CP_Const() would be more worth while as built in libraries are a lot more convenient to use which I think is the point.

I would have thought that a normal array would be able to implicitly cast to a constant array, but I guess you would know as you wrote the software :)
Graham Ambrose

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#10 Post by zristic » 27 May 2005 17:20

gambrose wrote:I would have thought that a normal array would be able to implicitly cast to a constant array, but I guess you would know as you wrote the software
Const array is in flash, it is read via TBLRD commands and it is invariable. Var array is in RAM and it is read by accessing the right register at the right moment. It can be changed at run time.

Post Reply

Return to “mikroC General”