2014-01-02 02:47 AM
struct tm time;
char year[50]; Guys, I want to display year into LCD screen but I got 00 on LCD, any clues on how to do it ? thanks printf(''Time: %d-%d-%d %02d:%02d:%02d \r\n'', time.tm_year, \ time.tm_mon+1, time.tm_mday,\ time.tm_hour, time.tm_min, time.tm_sec); sprintf(year,''%.2f'',time.tm_year);lcd_string(year); #!complicated
2014-01-02 02:40 PM
''I'm using MDK-ARM, isn't it gcc ?''
Most definitely
not
!Keil (an ARM company) makes & sells tools on a commercial, closed-source basis.2014-01-03 04:28 AM
2014-01-03 04:32 AM
I tried to run it, it's freezed in the middle, any suggestions ??
2014-01-03 04:53 AM
Hi again
''I tried to run it, it's freezed in the middle, any suggestions ??'' Can you tell us what you do see? What happens when you step through the code, where does it stop? You did not answer my question : Where is the printf going to ? (Embedded systems do not normally have a console - so where is the printf directing to?) What happens in the lcd_string() when the char is not an ASCII char?2014-01-03 05:13 AM
I tried to run it, it's freezed in the middle, any suggestions ??
You'll need to use a debugger, and be more specific. The utility of the time/year values would depend on them being correctly set and read from the RTC. printf() would require some kind of semi-hosting in Keil to push the data out a Serial or SWV connection. Absent that you'll likely end up in the Hard Fault routine, as the result of an BKPT/SWI instruction trying to call some support functions. You could implement a better Hard Fault handler, but again this would require some output device/mechanism.2014-01-03 05:59 AM
printf is going to print a text on terminal (USART)
2014-01-03 06:01 AM
2014-01-03 06:13 AM
Why did you choose Keil then??
Go to the line you want to stop on, Debug menu - insert breakpoint (or just press F9) Then run (F5). When the line of code is reached - the debugger should stop and wait for your next operation. You can single step (step into) or step over Step out or Run2014-01-03 08:00 AM
Is printf working as you expect? i.e. if you comment out the call to lcd_string does it work as expected? It's not obvious to me where your problem lies i.e. printf or lcd_string. It is always a good ides to cut a problem down to it's simplest form and be as specific as possible when describing the issue.
And good advise above re single stepping to where the problem lies.2014-01-04 04:45 AM