This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Old Code working once properly newly compiled does no longer work properly

The code given below with the date from 2013 in the constant string was complied and exectued correctly in Februar 2013. SAB80C535 and LCD Modul in eight Bit Modus.

Today with the changed date for next year the code was compiled and linked witout any error message but does no longer execute properly on the hardware. Either the the display is not initialzied or the float value is not written to the dispaly or the float value is zero.

If the float operations are deleted, the remaining programm is executed properly.

If only sqrt is computed and written to the string, the string is correctly written to the display. All other char strings and their LCD operations deleted.

Compiling is in Large Code and Large Memory Model. Compiler is the same as in February.
The SAB 80C535 has 56k external RAM. Hardware the same as before.

No clue what has happend since February. The project is unaltered in folders, projectfile and so on, except for the content of the one constant string with the date. And the length of the string is 19 characters plus /n as before.

 #include <reg515.h>
 #include <lcd.h>
 #include <math.h>
 #include <stdio.h>


void main(void)
{

char select;

float x;

xdata char zeile1[20] = "Berufskolleg Hilden";
xdata char zeile2[20] = " 15. November 2014 ";
xdata char zeile3[20] = "   Kreis Mettmann  ";
xdata char zeile4[20] = "    IT-Abteilung   ";
xdata char zeile5[20] = "   Mikrocontroller ";
xdata char zeile6[20] = "   Digitaltechnik  ";
xdata char zeile7[20] = " Schlüsselverfahren";
xdata char zeile8[20] = "                   ";

 init(1,1,0);
 display_on_off(1,1,0);
 entry(1,0);
 home();
 clrscr();

lcdadr(0);
datschreib(zeile1);
lcdadr(63);
datschreib(zeile2);
lcdadr(20);
datschreib(zeile3);

 x = sqrt(2.0);
 printf(zeile8 , "%14.6f" , x);

do
{
                 switch(select % 5)
                 {
                        case 0 :
                                 {
                                        lcdadr(84);
                                        datschreib(zeile4);
                                        warte(2000);
                                        break;
                                }
                        case 1 :
                                {
                                        lcdadr(84);
                                        datschreib(zeile5);
                                        warte(2000);
                                        break;
                                }
                        case 2 :
                                {
                                        lcdadr(84);
                                        datschreib(zeile6);
                                        warte(2000);
                                        break;
                                }
                        case 3 :
                                {
                                        lcdadr(84);
                                        datschreib(zeile7);
                                        warte(2000);
                                        break;
                                }
                        case 4 :
                                {
                                        lcdadr(84);
                                        datschreib(zeile8);
                                        warte(2000);
                                        break;
                                }
                }

                select++;

        }while(1);
 }

Inhalt von lcd.h

void warte (unsigned int zeit);
void init(bit D, bit N, bit F);
void clrscr(void);
void home(void);
void entry(bit ID, bit S);
void display_on_off(bit D, bit C, bit B);
void datschreib(char *z);
void lcdadr(char a7);

Parents
  • The "printf" & "sprintf" functions can be troublesome on some controllers. Like for example, yesterday nite, i was using the function to convert integer into ascii on an 8051controller.
    And the unfortunately, the converted string was never displayed on the LCD. An extra 30mins or so, was wasted in figuring out that problem.
    I, then wrote own itoa function and instantly everything was working.
    (I has downloaded the latest evaluation version of keil c51)

    So, if the other strings are being displayed on the LCD, and only the converted string is not being printed then you know where the problem is.

Reply
  • The "printf" & "sprintf" functions can be troublesome on some controllers. Like for example, yesterday nite, i was using the function to convert integer into ascii on an 8051controller.
    And the unfortunately, the converted string was never displayed on the LCD. An extra 30mins or so, was wasted in figuring out that problem.
    I, then wrote own itoa function and instantly everything was working.
    (I has downloaded the latest evaluation version of keil c51)

    So, if the other strings are being displayed on the LCD, and only the converted string is not being printed then you know where the problem is.

Children
  • So, if the other strings are being displayed on the LCD, and only the converted string is not being printed then you know where the problem is.

    Nonsense. Just because a change removed a bug doesn't mean that the thing that changed actually was the problem. And it definitely doesn't mean the problem is the same in every single case that shows vaguely similar symptoms.

  • ...doesn't mean that the thing that changed actually was the problem.
    Well, i didnt mean that the "sprintf" or "printf" is/was the problem. But the bug will be solved by looking into the implementation of the function.