Using Current Time

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using Current Time

675 Views
ahmed007
Contributor II

Greetings,

I am currently working with the LPCXpresso55S16 board and have encountered an issue while trying to obtain the current time using the time.h header file. After importing the header and executing the code:

time_t rawtime; time(&rawtime);
 

The variable "rawtime" receives a value of -1, indicating that the time retrieved is not correct. I am seeking assistance to resolve this problem and find a way to obtain the accurate current time using the LPCXpresso55S16 board.

Additionally, I attempted to use the real-time clock (rtc), but I encountered difficulties in its implementation.

If anyone could offer guidance on resolving the time retrieval issue or provide instructions on how to properly utilize the rtc functionality on the LPCXpresso55S16 board, I would greatly appreciate it.

Thank you for your assistance.

Best regards,

Ahmed Bouzid.

Labels (1)
0 Kudos
Reply
3 Replies

652 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @ahmed007,

Could you please check the rtc_example of the SDK_2.13.0_LPCXpresso55S16? It could be useful to start. You could download the SDK here: Welcome | MCUXpresso SDK Builder.

Are you having an specific problem using the SDK example? Could you please tell us more about the difficulties you are experiencing in your RTC implementation?

Best regards, Raul.

0 Kudos
Reply

627 Views
ahmed007
Contributor II

Dear @RaRo ,

 

I appreciate your response. Firstly, my main objective is to obtain the current time for use in my project. Initially, I believed that the time library would suffice for this purpose. However, after encountering the -1 issue, I came across some comments suggesting the use of RTC (Real-Time Clock) to fetch the current time using LPCXpresso. Consequently, I attempted to implement the RTC example from the SDK, despite not requiring the whole example, but rather just a function that can return the current time. Unfortunately, I encountered some difficulties, and here is the problem I faced.

The program execution gets stuck in this particular function:

index = GETCHAR(); 

Upon further investigation, I discovered that the code is blocked at this point, making it impossible to proceed with the step-by-step execution:

/* See fsl_debug_console.h for documentation of this function. */
int DbgConsole_Getchar(void)
{
char ch;
/* Do nothing if the debug UART is not initialized. */
if (kSerialPort_None == s_debugConsole.serial_port_type)
{
return -1;
}
while (kStatus_HAL_UartSuccess !=
s_debugConsole.getChar((hal_uart_handle_t)&s_debugConsole.uartHandleBuffer[0], (uint8_t *)(&ch), 1))
{
return -1;
}

return (int)ch;

in the : s_debugConsole.getChar.  in the : HAL_UartReceiveBlocking function the following line :  status = USART_ReadBlocking(s_UsartAdapterBase[uartHandle->instance], data, length); make the error. 

If there is a straightforward code or a simple method to obtain the current time, it would be greatly appreciated.

 

Best regards,

Ahmed.

0 Kudos
Reply

621 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @ahmed007,

Just for double check, are you using the complete example, or have you modified it? Which SDK and IDE are you using to run the example? Is this behavior happening while debugging? Have you modified in some way your jumper settings or development board?

Finally, could you please check another example like led_blinky? Is the behavior still happening? This is to check if is something relating the example or there is other thing.

Best regards, Raul.

0 Kudos
Reply