Reputation: 843
I am trying to set RTC time on STM32L051T6
microcontroller using epoch
time. So following is my code.
void Rtc_SetTime(uint32_t time_)
{
struct tm* brokenTime;
const time_t temp = 3600;
brokenTime = gmtime(&temp);
if (NULL == brokenTime)
{
printf("Error: Failed to convert time.\r\n");
}
}
When I call above function. It always goes to if
statement and prints Error. I have tried passing values 3600, 1459841178 as arguments. All fails. What is wrong with the code?
Upvotes: 2
Views: 2693
Reputation: 843
I used localtime() function instead of gmtime() and it works well solving my purpose.
Upvotes: 0
Reputation: 9753
I found the following here: http://support.raisonance.com/content/gmtime-and-localtime-broken-arm-gcc-lib
So it might not be implemented....
I think gmtime and localtime is broken in arm-gcc lib for STM32F10x.
I have try it in keil uVision and working fine there(localtime anyway, gmtime not implemented in keil). gmtime and localtime is searching for _sbrk when linking.
"sbrkr.c: (.text+0xc): undefined reference to `_sbrk'"
Upvotes: 1