pmSetSpeed (Function)

Top  Previous  Next

Architecture:

X32 / NX32

Device support:

All

Firmware version:

1.02


This function is used to set the CPU execution speed to reduce the power consumption. The speed is selected in five steps (0..4) where 0 is slowest. However, when changing to another speed, a number of limitations exist.

 

Limitations:

If another function, which must operate at a higher speed than the one requested, is enabled, an error will be returned. Please see the return codes.

A voice call will temporarily switch to full speed (4) as long as the call is active.

When the on-board battery is being charged, the device will operate at full speed (4) until charging has terminated.

Connecting a programming cable will temporary switch to full speed (4) to enable communication with the RTCU IDE. The selected speed is resumed when the cable is removed.

Using gsmPower is only allowed at speed 3 or 4. Use gsmPowerLP for all other speeds.

When the speed is changed, all serial communication is interrupted, and the RTCU cannot receive any data that is transmitted to it during the change. This includes CAN, 1-Wire, RS232, and RS485.

Operating CAN at 1 Mbit is only allowed at speed 1 or higher.

1-Wire is only allowed at speed 4.

On-board Ethernet is only allowed at speed 4.

It is not possible for RS232 and RS485 to obtain all baud rates at all speeds. Below is an overview of which baud rates that can be used at the specific CPU execution speed.

 

clip0019

 

Input:                

speed : INT

    0 = Very slow (2 MHz clock).

    1 = Slow (6 MHz clock).

    2 = Medium (12 MHz clock).

    3 = Fast (24 MHz clock).

    4 = Very fast (48 MHz clock) (default at boot-up).

 

Returns: INT

0

- Success.

1

- Invalid speed.

2

- CAN communication speed is too high for the requested speed.

3

- GSM is not in low power mode. See gsmPowerLP.

4

- Baud rate selected on serial port 0 does not support the requested speed.

5

- Baud rate selected on serial port 1 does not support the requested speed.

6

- Baud rate selected on serial port 2 does not support the requested speed.

7

- Bluetooth does not support the requested speed.

8

- GPS update frequency does not support the requested speed.

9

- On-board Ethernet does not support the requested speed.

 

 

Declaration:

FUNCTION pmSetSpeed : INT;
VAR_INPUT
  speed : INT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  ext_pwr : BOOL;
END_VAR;
 
gsmPowerLP(power:=ON);
gprsOpen();
DebugFmt(message:="pmPowerFail=\1",v1:=pmPowerFail(bat:=TRUE));
 
BEGIN
  ...
  IF boardSupplyType() = 1 AND ext_pwr THEN
     ext_pwr := FALSE;
    pmSetSpeed(speed:=2);
  ELSIF boardSupplyType() = 2 AND NOT ext_pwr THEN
     ext_pwr := TRUE;
    pmSetSpeed(speed:=4);
  END_IF;
  ...
END;
END_PROGRAM;