|
|
|
Bean
ADC
|
A/D converter
Methods are user callable functions/subroutines that are means of controlling the bean functions.
|
Methods:
-
Enable
- Enables A/D converter bean. Events may be generated (DisableEvent/EnableEvent). If possible, this method switches on A/D converter device, voltage reference, etc.
ANSIC prototype: byte Enable(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
Disable
- Disables A/D converter bean. No events will be generated. If possible, this method switches off A/D converter device, voltage reference, etc.
ANSIC prototype: byte Disable(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
EnableEvent
- Enables the events.
ANSIC prototype: byte EnableEvent(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
DisableEvent
- Disables the events.
ANSIC prototype: byte DisableEvent(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
Start
- This method starts continuous conversion on all channels that are set in the bean inspector. When each measurement on all channels has finished the OnEnd event may be invoked. This method is not available if the interrupt service is disabled and the device doesn't support the continuous mode. Note: If time of measurement is too short and the instruction clock is too slow then the conversion complete interrupt and its handler may cause a system overflow.
ANSIC prototype: byte Start(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - Device is disabled ERR_BUSY - A conversion is already running
-
Stop
- This method stops the continuous measurement, which had been started by Start method, or this method disables a trigger mode which has been enabled by EnableInt(Chan)Trigger or EnableExt(Chan)Trigger method (if these are supported by HW). This method is available if at least one of Start, EnableInt(Chan)Trigger or EnableExt(Chan)Trigger methods is supported by A/D converter device and it is enabled to be generated.
ANSIC prototype: byte Stop(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_BUSY - No continuous measurement is running. Neither internal trigger nor external trigger have been enabled (if these are supported by HW).
-
Measure
- This method performs one measurement on all channels that are set in the bean inspector. (Note: If the number of conversions is more than one the conversion of A/D channels is performed specified number of times.)
ANSIC prototype: byte Measure(bool WaitForResult)
- WaitForResult:bool - Wait for a result of a conversion. If interrupt service is disabled, A/D peripheral doesn't support measuring all channels at once or Autoscan mode property isn't enabled and at the same time the number of channel is greater than 1, then the WaitForResult parameter is ignored and the method waits for each result every time. If the interrupt service is disabled and a number of conversions is greater than 1, the parameter is ignored and the method also waits for each
result every time.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - Device is disabled ERR_BUSY - A conversion is already running
- Methods for HCS12/HCS12X derivatives.
-
MeasureWait
- This method performs one measurement on all channels that are set in the bean inspector and then waits till the end of the measurement. (Note: If the number of conversions is more than one the conversion of A/D channels is performed specified number of times.)
ANSIC prototype: byte MeasureWait(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - Device is disabled ERR_BUSY - A conversion is already running
-
MeasureNotWait
- This method performs one measurement on all channels that are set in the bean inspector and doesn't wait till the end of the measurement. (Note: If the number of conversions is more than one the conversion of A/D channels is performed specified number of times.)
ANSIC prototype: byte MeasureNotWait(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - Device is disabled ERR_BUSY - A conversion is already running
-
MeasureChan
- This method performs measurement on one channel. (Note: If the number of conversions is more than one the conversion of the A/D channel is performed specified number of times.)
ANSIC prototype: byte MeasureChan(bool WaitForResult,byte Channel)
- WaitForResult:bool - Wait for a result of conversion. If the interrupt service is disabled and at the same time a number of conversions is greater than 1, the WaitForResult parameter is ignored and the method waits for each result every time.
- Channel:byte - Channel number. If only one channel in the bean is set this parameter is ignored, because the parameter is set inside this method.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - Device is disabled ERR_BUSY - A conversion is already running ERR_RANGE - Parameter "Channel" out of range
- Methods for Freescale HCS12/HCS12X derivatives.
-
MeasureChanWait
- This method performs one measurement on one channel and waits till the end of the measurement. (Note: If the number of conversions is more than one the conversion of A/D channels is performed specified number of times.)
ANSIC prototype: byte MeasureChanWait(byte Channel)
- Channel:byte - Channel number. If only one channel in the bean is set then this parameter is ignored, because the parameter is set inside this method.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - Device is disabled ERR_BUSY - A conversion is already running ERR_RANGE - Parameter "Channel" out of range
-
MeasureChanNotWait
- This method performs one measurement from one channel and doesn't wait till the end of the measurement. (Note: If the number of conversions is more than one the conversion of A/D channels is performed specified number of times.)
ANSIC prototype: byte MeasureChanNotWait(byte Channel)
- Channel:byte - Channel number. If only one channel in the bean is set then this parameter is ignored, because the parameter is set inside this method.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - Device is disabled ERR_BUSY - A conversion is already running ERR_RANGE - Parameter "Channel" out of range
-
EnableExtTrigger
- Enables the trigger mode. If an active edge or an active level (property Trigger active) is detected, conversion of all channels that are set in the bean inspector is performed. If the Number of conversions property is greater than 1, a conversion is needed to be launched more than once (by external signal) according to a specified value of Number of conversions. It's possible to disable the trigger mode by Stop method. This EnableExtTrigger method is available only when the Trigger feature property is enabled.
ANSIC prototype: byte EnableExtTrigger(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_BUSY - A conversion is already running
-
EnableExtChanTrigger
- Enables the trigger mode. If an active edge or an active level (property Trigger active) is detected, a conversion of only one required channel will be performed. If the Number of conversions is greater than 1, a conversion will be launched more than once (by an external signal) according to Number of conversions. It's possible to disable the trigger mode by Stop method. This EnableExtChanTrigger method is available only when Trigger feature property is enabled.
ANSIC prototype: byte EnableExtChanTrigger(byte Channel)
- Channel:byte - Channel number which will be measured on an external trigger (control). If only one channel in the bean is set then this parameter is ignored.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_BUSY - A conversion is already running ERR_RANGE - Parameter "Channel" out of range
- Methods for Freescale 56800 and HCS12X derivatives.
-
EnableIntTrigger
- Enables the internal trigger mode. A conversion of all channels that are set in the bean inspector will be launched by an internal sync pulse. If the Number of conversions is greater than 1, a conversion will be launched more than once (by an internal signal) according to Number of conversions. It's possible to disable the trigger mode by Stop method. This EnableIntTrigger method is available only when the Internal trigger property is enabled.
ANSIC prototype: byte EnableIntTrigger(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_BUSY - A conversion is already running
- Methods for Freescale 56800, HCS12X and HCS08 AW60, QG8, QG4 and RT16 derivatives.
-
EnableIntChanTrigger
- Enables the internal trigger mode. A conversion of one required channel will be launched by internal sync pulse. If the Number of conversions property is greater than 1, a conversion will be launched more than once (by an internal signal) according to Number of conversions. It's possible to disable the trigger mode by Stop method. This EnableIntChanTrigger method is available only when the Internal trigger property is enabled.
ANSIC prototype: byte EnableIntChanTrigger(byte Channel)
- Channel:byte - Channel number which will be measured at internal trigger control. If only one channel in the bean is set then this parameter is ignored.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_BUSY - A conversion is already running ERR_RANGE - Parameter "Channel" out of range
-
GetValue
- Returns the last measured values for all channels. Format and width of the value is a native format of the A/D converter.
ANSIC prototype: byte GetValue(void* Values)
- Values:void* - Pointer to the array that contains the measured data. Data type is a byte, a word or an int. It depends on the supported modes, resolution, etc. of the AD converter. See the Version specific information for the current CPU in General Info.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_NOTAVAIL - Requested value not available ERR_OVERRUN - External trigger overrun flag was detected after the last value(s) was obtained (for example by GetValue). This error may not be supported on some CPUs (see generated code).
-
GetChanValue
- Returns the last measured value of the required channel. Format and width of the value is a native format of the A/D converter.
ANSIC prototype: byte GetChanValue(byte Channel,void* Value)
- Channel:byte - Channel number. If only one channel in the bean is set then this parameter is ignored.
- Value:void* - Pointer to the measured value. Data type is a byte, a word or an int. It depends on the supported modes, resolution, etc. of the AD converter. See the Version specific information for the current CPU in General Info.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_NOTAVAIL - Requested value not available ERR_RANGE - Parameter "Channel" out of range ERR_OVERRUN - External trigger overrun flag was detected after the last value(s) was obtained (for example by GetValue). This error may not be supported on some CPUs (see generated code).
-
GetValue8
- This method returns the last measured values of all channels justified to the left. Compared with GetValue method this method returns more accurate result if the number of conversions is greater than 1 and AD resolution is less than 8 bits. In addition, the user code dependency on AD resolution is eliminated.
ANSIC prototype: byte GetValue8(byte *Values)
- Values: Pointer to byte - Pointer to the array that contains the measured data.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_NOTAVAIL - Requested value not available ERR_OVERRUN - External trigger overrun flag was detected after the last value(s) was obtained (for example by GetValue). This error may not be supported on some CPUs (see generated code).
-
GetChanValue8
- This method returns the last measured value of required channel justified to the left. Compared with GetChanValue method this method returns more accurate result if the number of conversions is greater than 1 and AD resolution is less than 8 bits. In addition, the user code dependency on AD resolution is eliminated.
ANSIC prototype: byte GetChanValue8(byte Channel,byte *Value)
- Channel:byte - Channel number. If only one channel in the bean is set then this parameter is ignored.
- Value: Pointer to byte - Pointer to the measured value.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_NOTAVAIL - Requested value not available ERR_RANGE - Parameter "Channel" out of range ERR_OVERRUN - External trigger overrun flag was detected after the last value(s) was obtained (for example by GetValue). This error may not be supported on some CPUs (see generated code).
-
GetValue16
- This method returns the last measured values of all channels justified to the left. Compared with GetValue method this method returns more accurate result if the number of conversions is greater than 1 and AD resolution is less than 16 bits. In addition, the user code dependency on AD resolution is eliminated.
ANSIC prototype: byte GetValue16(word *Values)
- Values: Pointer to word - Pointer to the array that contains the measured data.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_NOTAVAIL - Requested value not available ERR_OVERRUN - External trigger overrun flag was detected after the last value(s) was obtained (for example by GetValue). This error may not be supported on some CPUs (see generated code).
-
GetChanValue16
- This method returns the last measured value of the required channel justified to the left. Compared with GetChanValue method this method returns more accurate result if the number of conversions is greater than 1 and AD resolution is less than 16 bits. In addition, the user code dependency on AD resolution is eliminated.
ANSIC prototype: byte GetChanValue16(byte Channel,word *Value)
- Channel:byte - Channel number. If only one channel in the bean is set then this parameter is ignored.
- Value: Pointer to word - Pointer to the measured value.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_NOTAVAIL - Requested value not available ERR_RANGE - Parameter "Channel" out of range ERR_OVERRUN - External trigger overrun flag was detected after the last value(s) was obtained (for example by GetValue). This error may not be supported on some CPUs (see generated code).
Note: Some methods can be implemented as macros.
|
|
|
Processor ExpertTM and Embedded BeansTM are registered trademarks of UNIS, Ltd.
©1997-2005, UNIS, Ltd.
|
|
|