2018-05-01 03:39 AM
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.
Solved! Go to Solution.
2018-05-01 09:48 AM
The last questions refers to compiler messages like the one you show earlier (spriinf() declared implicitely , etc)
2018-05-01 04:34 AM
'buf' variable definition? Is the memory for 'buf' allocated?
For example, you can reserve some memory this way:
char buf[100];
2018-05-01 06:44 AM
Add at the beginning:
#include <string.h>
2018-05-01 07:43 AM
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?
2018-05-01 08:37 AM
Yeah, the LCD is 2*16 and this is the code.
2018-05-01 09:23 AM
Did it.But no result.
2018-05-01 09:48 AM
The last questions refers to compiler messages like the one you show earlier (spriinf() declared implicitely , etc)
2018-05-01 10:15 AM
>On my LCD or in the message box of the compiler?
In the compile window
2018-05-01 10:40 AM
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.2018-05-01 12:13 PM
Bogdan Golab wrote:
Is the 'HELLO WORLD' correctly displayed in the position of 0,2?
Yes, it's ok and in its proper position.
Bogdan Golab wrote:
Do yo still see 1,2,... instead of 100?
I just see 18501 instead of 100 at first, then after 30 seconds, I see 12594.
What messages do you see now?
On my LCD or in the message box of the compiler?