The RTC is used by TI-RTOS as the time base for the ti.sysbios.Clock module. It continues to run even when the processor is in standby mode and will wake the processor whenever a Clock object times out.
Clock objects are used to implement the timeouts for BIOS APIs such as Task_sleep(), Semaphore_pend(), Event_pend(), etc. They are also used internally by various TI-RTOS driver functions when a timeout is required.
Clock objects are used to implement the timeouts for BIOS APIs such as Task_sleep(), Semaphore_pend(), Event_pend(), etc. They are also used internally by various TI-RTOS driver functions when a timeout is required.
The RTC is also used as the timebase for the ti.sysbios.hal.Seconds module which can be used to provide time-of-day information to your application.
/*
* ======== clock.c ========
*/
/* XDC module Headers */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
/* BIOS module Headers */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
/* Example/Board Header files */
#include "Board.h"
Void clk0Fxn(UArg arg0);
Void clk1Fxn(UArg arg0);
Clock_Struct clk0Struct, clk1Struct;
Clock_Handle clk2Handle;
/*
* ======== main ========
*/
Int main()
{
/* Construct BIOS Objects */
Clock_Params clkParams;
/* Call driver init functions */
Board_initGeneral();
Clock_Params_init(&clkParams);
clkParams.period = 5000/Clock_tickPeriod;
clkParams.startFlag = TRUE;
/* Construct a periodic Clock Instance */
Clock_construct(&clk0Struct, (Clock_FuncPtr)clk0Fxn,
5000/Clock_tickPeriod, &clkParams);
clkParams.period = 0;
clkParams.startFlag = FALSE;
/* Construct a one-shot Clock Instance */
Clock_construct(&clk1Struct, (Clock_FuncPtr)clk1Fxn,
11000/Clock_tickPeriod, &clkParams);
clk2Handle = Clock_handle(&clk1Struct);
Clock_start(clk2Handle);
BIOS_start(); /* does not return */
return(0);
}
/*
* ======== clk0Fxn =======
*/
Void clk0Fxn(UArg arg0)
{
UInt32 time;
time = Clock_getTicks();
System_printf("System time in clk0Fxn = %lu\n", (ULong)time);
}
/*
* ======== clk1Fxn =======
*/
Void clk1Fxn(UArg arg0)
{
UInt32 time;
time = Clock_getTicks();
System_printf("System time in clk1Fxn = %lu\n", (ULong)time);
System_printf("Calling BIOS_exit() from clk1Fxn\n");
BIOS_exit(0);
}