Skip to main content
Visitor II
May 1, 2018
Solved

Problem in displaying a number on char LCD displays

  • May 1, 2018
  • 5 replies
  • 2243 views
Posted on May 01, 2018 at 12:39

Hi.

I was working with my new stm8s105 MCU trying to get started with the timers.

But every time I use the command to display the time on the LCD the same number showed every time.I thought that the problem is my timer code but when I just put a number on the LCD to show it just showed an irrelevant number.

I use the same LCD.h on LPC1768 and STM32F2 and just converted the same header.The only difference is that I used Keil compiler for them and now I'm using IAR.

lcd_gotoxy(1,2);

sprintf(buf,'%d',100);

lcd_print(buf);

delay_ms(1000);

This is a simple code that must show 100 but it displays 12594

>:(

The characters are displayed properly.The problem is numbers.

    This topic has been closed for replies.
    Best answer by Bogdan Golab
    Posted on May 01, 2018 at 16:48

    The last questions refers to compiler messages like the one you show earlier (spriinf() declared implicitely , etc)

    5 replies

    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 13:34

    'buf' variable definition? Is the memory for 'buf' allocated?

    For example, you can reserve some memory this way:

    char buf[100];

    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 15:37

    Yeah, the LCD is 2*16 and this is the code.

    0690X00000604g0QAA.jpg
    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 15:44

    Add at the beginning:

    #include <string.h>

    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 16:23

    Did it.But no result.

    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 16:43

    Is the 'HELLO WORLD' correctly displayed in the position of 0,2?

    Do yo still see 1,2,... instead of 100?

    What messages do you see now?

    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 16:48

    The last questions refers to compiler messages like the one you show earlier (spriinf() declared implicitely , etc)

    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 19:27

    I don't know why does this message 'declared implicitly' is shown in the message box and I don't know what is it at all.

    When I use this header in stm32f no such warning appears!!

    Is it the problem?

    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 19:15

    >On my LCD or in the message box of the compiler?

    In the compile window

    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 19:40

    I was wrong - the sprintf is a part of:

    #include <

    https://pl.wikibooks.org/wiki/C/Biblioteka_standardowa/Indeks_tematyczny#stdio.h

    >

    So include the stdio.h as shown above to clear the message and test it again.
    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 21:45

    Yes.My problem is fixed using stdio.h.

    Thanks

    Visitor II
    May 1, 2018
    Posted on May 01, 2018 at 21:55

    Sometimes it take time when you do not see all Warnings from the console. I usually clear all Warnings before I test the software.

    Thanks for letting me know!