adc

ADC hardware, built-in PIC ADC module

Author Stef Mientki, Copyright (c) 2002..2008, all rights reserved.
Adapted-by Sebastien Lelong.
Compiler >=2.4k

Description

library to handle ADC peripheral.
  - support both low and high resolution mode
  - support a large number of PICs, with
      - ADC pin configuration
      - channel selection
      - clock selection
  - support Vref



How to use it ? See http://justanotherlanguage.org/content/jallib/tutorials/tutorial_adc_intro


Notes

this is a heavy refactoring/rewriting of original library from Stef Mientki.
The main changes are about ADC configuration, which are essentially handled in
adc_channels.jal and adc_clock.jal.



About Vref setup:
  - when ADC_NVREF = ADC_NO_VREF : there's no Vref pin used, vref is done
                     internally, using power supply (Vdd, Vss)
  - when ADC_NVREF = ADC_VREF_POS ): there's only one Vref pin, this is Vref+
  - when ADC_NVREF = ADC_VREF_POS_NEG : two Vref pins are used, Vref+ and Vref-
  - when ADC_NVREF = ADC_VREF_NEG : there's only one Vref pin, this is Vref-






A major trigger is when using ADC libs is ADC_DYNAMIC. When declared, several parameters
become dynamic and can be changed at runtime. This includes:
   - ADC_NCHANNEL, the number of ADC channels (when they are dependent channels,
     as independent channels are always selected at runtime with set_analog_pin()
   - ADC_TEMP (careful, computation related to temperature very approximative
   - ADC_RESOLUTION (8-bits or 10-bits)
   - ADC_RSOURCE



The original library can be found:
   - Stef's: http://mientki.ruhosting.nl/pic-tools/jal/libs2/adc_hardware.jal
   - jallib issue tracker: http://code.google.com/p/jallib/issues/detail?id=7


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

  • adc_read_bytes(byte in adc_chan, byte out adc_hbyte, byte out adc_lbyte)

    Does an AD conversion on the selected channel
    returns the 10-bit result as 2 byte parameters
    It doesn't matter if ADC is set to low or high resolution
    

  • adc_init()

    Initializes the PIC AD-converter,
    by calling the correct routine according to the number of external references
    Settings are done according to the special ADC constants
    Sets all the analog pins to input
    Calculates aquisition time and determines if right or
    left justification is optimal
    

Private

Functions


Related samples

Here are the list of samples which use this library:

12f68312f683_pwm_adc.jal
16f72316f723_adc_independent.jal
16f7316f73_adc_dependent.jal
16f76716f767_pwm_adc.jal
16f7716f77_adc_lowres.jal
16f876a16f876a_adc.jal
16f87716f877_adc_dependent.jal
16f87716f877_adc.jal
16f877a16f877a_adc_dependent.jal
16f8816f88_adc_independent.jal
16f8816f88_adc_lowres.jal
16f8816f88_adc_highres.jal
16f88616f886_pwm_adc_res.jal
16f88616f886_pwm_adc_freq.jal
18f14k5018f14k50_adc_independent.jal
18f245018f2450_adc_dependent.jal
18f455018f4550_adc.jal
18f455018f4550_adc_dependent.jal
18f455018f4550_dynamic_adc.jal