You are here: Home DOCUMENTATION Reference nqBASIC API

nqBASIC

nqBASIC API

Article Index
nqBASIC API
CAN
DIO
I2C
LCD
PWM
RTI
SCI
SPI
SYSTEM
TIMIO
WDT
WIRE1
All Pages

 

ADC  
Analog-to-Digital Converter Subsystem

Version:
1.0.0
Targets:
Nanocore12, Nanocore12DX, Nanocore12MAX



Constructor Function Summary
ADC(const <Pins>)
One or more analog input(s) can be specified in the constructor of an ADC object.


Object Function Summary
ADC_Read(const <Pin>, out byte/word result)
Get a value from an analog pin.
ADC_Start(in byte wait, in byte mode)
Start the Analog to Digital Converter


Class Function Summary
ADC_Done(out byte done)
Check if the ADC has finished the conversion.

Constructor Function Detail

ADC

ADC(const <Pins>)

More than one analog input can be specified in the constructor of an ADC object, as long as the listed pins form a valid AD sequence for the HCS12. The only restriction is that all the pins specified must be adjacent. Note that PAD07 and PAD00 are also considered to be adjacent analog inputs.

Parameters:
const <Pins>- Array of pins for ADC object to be associated with
Example:
dim myADC0 as new ADC(PAD00, PAD01)


Object Function Detail

ADC_Read

ADC_Read(const <Pin>, out byte/word result)

Get a value from an analog pin.

Parameters:
const <Pin>- Analog pin part of ADC object to read
out byte/word result- Result of conversion (use word if getting a 10-bit value)
Example:
myADC0.ADC_Read (PAD00, myResult)

ADC_Start

ADC_Start(in byte wait, in byte mode)

Initiate an analog-to-digital conversion

Parameters:
in byte wait- When WAIT will block until the conversion is complete
in byte mode-
Four possible modes: ADC_MODE_8ONCE: single 8-bit conversion
ADC_MODE_8CONTINUOUS: continuous 8-bit conversion
ADC_MODE_10ONCE: single 10-bit conversion
ADC_MODE_10CONTINUOUS: continuous 10-bit conversion

Example:
myADC0.ADC_Start (WAIT, ADC_MODE_8ONCE)


Class Function Detail

ADC_Done

ADC_Done(out byte done)

Return the status of the ADC Conversion Complete flag

Parameters:
out byte done- Returns 1 if conversion complete, 0 if still in progress
Example:
ADC.ADC_Done(myResult)


 

Add comment


Security code
Refresh