| aServo_SetConfig | Index |
Definition:
Parameters:
Return Value:
Description:
This routine configures a servo output. The configuration bits determine whether the servo is enabled or inverted, the output state if the servo is disabled, and the speed of the servo.
Three defined flag values may be used to configure servo outputs:
| SRV_ENA | 128 | Set to enable the PWM output at a servo pin. Clear to disable the PWM output at a servo pin. |
| SRV_INV | 64 | Set to use inverted positions for a servo. Clear to use normal positions for a servo. |
| SRV_DSTA | 32 | Set to make the servo output remain high when the PWM is disabled. Clear to make the servo output remain low when the PWM is disabled. |
Add or logical-OR a value from 1 to 15 to the configuration bits to perform a speed-controlled servo motion. The value 1 is the slowest speed and 15 is the fastest. A speed of 0 will disable the speed function and make the servo move from one position to another as fast as it can go.
Example:
aServo_SetConfig(3, (unsigned char)((SRV_ENA | SRV_INV) + 12));
This would configure servo PWM output 3 to be enabled and inverted. Its speed is 12. A typecast in the expression ensures that the compiler will accept the value.
aServo_SetConfig(0, (unsigned char)(SRV_ENA | 15));
This would configure servo PWM output 0 to be enabled but not inverted and have a speed of 15.
aServo_SetConfig(0, (unsigned char)0);
This would configure servo PWM output 0 to be disabled and set to an output state of 0.
aServo_SetConfig(0, (unsigned char)SRV_DSTA);
This would configure servo PWM output 0 to be disabled and set to an output state of 1.
Related: