clockSetWakeup (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.36.00


This function is used to configure the system to wake from suspend at a specific time.

It can e.g. be used to wake at midnight so the device can send a report.

The time can both be supplied as a linsec with an absolute time to wake at and the individual time components such as hour and minute.

If the time components are provided, the wake time will be set to an absolute time when the function is called, so it should be called just before calling pmSuspend.

When using time components, at least one part must be specified. All the parts that are larger than the specified parts will be ignored while all the parts that are smaller will be set to the current time.

The time will always be adjusted to be in the future, if e.g. a day is chosen that is smaller that the current day, it will trigger in the next month instead.

Examples:

Current time: 2019-04-02 15:44

Setting month = 5: 2019-05-02 15:44

Setting hour = 0: 2019-04-03 00:44

Setting minute = 30: 2019-04-02 16:30

 

 

Note that this can not be used while also using the time parameter on pmSuspend.

 

pmSuspend return codes for this wake-up source:

Error

Type

ID

Value

Description

True

1

1

-10

The time parameter on pmSuspend is in use.

True

1

1

-11

The wake up time is too soon.

False

1

1

1

Wake-up at the specific time.

 

 

Input:

 

Enable : BOOL (default: TRUE)

Set to true to enable the wake-up, set to false to disable it.

 

linsec : DINT (default: -1)

The linsec to wake at. If set to -1 it will not be used.

 

month : SINT (default: -1)

The month part of the wake-up time. If set to -1, the month will be ignored.

 

day : SINT (default: -1)

The day part of the wake-up time. If set to -1, the day will be ignored.

 

hour : SINT (default: -1)

The hour part of the wake-up time. If set to -1, the hour will be ignored.

 

minute : SINT (default: -1)

The minute part of the wake-up time. If set to -1, the minute will be ignored.

 

second: SINT (default: -1)

The second part of the wake-up time. If set to -1, the second will be ignored.

 

 

Returns:

1

- The system has been configured to wake at the specified time.

0

- This function is not supported.

-1

- The wake-up time could not be created.

 

Declaration:

FUNCTION ALIGN clockSetWakeup:INT;
VAR_INPUT
  enable: BOOL := TRUE;
  linsec: DINT := -1;
  month : SINT := -1;
  day   : SINT := -1;
  hour  : SINT := -1;
  minute: SINT := -1;
  second: SINT := -1;
END_VAR;
 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
 
BEGIN
  ...
  // Enable wake-up when minute and second are 0, i.e. when the hour starts.
  rc := clockSetWakeup(minute := 0, second := 0);
  DebugFmt(message:="clockSetWakeup: \4", v1 := rc);
  ...
  // Enable wake-up at 2019-12-24 12:00:30
  rc := clockSetWakeup(linsec := clockTimeToLinsec(year := 2019, month := 12, day := 24, hour:=12, minute:=0, second:=30));
  DebugFmt(message:="clockSetWakeup: \4", v1 := rc);
  ...
END;
 
END_PROGRAM;