Revision: 1771
Author: sebastien.lelong
Date: Fri Mar 12 12:06:34 2010
Log: clean adc_channels tmpl code, optimize 1 call stack when ADC libs runs
in a static mode, issue 114: handle vref selection with only Vref-
http://code.google.com/p/jallib/source/detail?r=1771
Modified:
/trunk/include/peripheral/adc/adc.jal
/trunk/include/peripheral/adc/adc_channels.jal
/trunk/include/peripheral/adc/adc_clock.jal
/trunk/tools/adc/adc_channels.jal.tmpl
=======================================
--- /trunk/include/peripheral/adc/adc.jal Thu Mar 11 23:13:18 2010
+++ /trunk/include/peripheral/adc/adc.jal Fri Mar 12 12:06:34 2010
@@ -157,6 +157,7 @@
procedure _adc_init_justify() is
+ pragma inline
-- Seb: justification is done through ADFM bits
-- They can be found in:
-- - ADCON0_ADFM
@@ -194,7 +195,7 @@
procedure _adc_init_acquisition_delay() is
-
+ pragma inline
-- Seb: holy datasheet says:
-- Tc = Chold * (Ric + Rss + Rs) * ln(0.0004885)
-- I don't know Ric and Rss are, but Rs is the impedance for analog
sources
@@ -247,6 +248,7 @@
-- Pin setup: analog as input, configure Vref, ...
procedure _adc_setup() is
+ pragma inline
_adc_setup_pins() -- conditionally defined according to PIC
_adc_vref() -- conditionally defined according to PIC
end procedure
@@ -258,7 +260,9 @@
-- Calculates aquisition time and determines if right or
-- left justification is optimal
procedure adc_init() is
- -- TODO: check dynamic to adjust inline
+ if defined(ADC_DYNAMIC) == false then
+ pragma inline
+ end if
_adc_setup()
-- calculate aquisition delay and optimize justify
_adc_init_justify()
=======================================
--- /trunk/include/peripheral/adc/adc_channels.jal Thu Mar 11 23:13:18 2010
+++ /trunk/include/peripheral/adc/adc_channels.jal Fri Mar 12 12:06:34 2010
@@ -21,6 +21,11 @@
-- 3. the number of channels is set using ANS bits (18F and non-18F)
-- => same as case 2., channels can be configured independently
-- Vref+/Vref- are configured using VCFG bits.
+-- --
+-- About Vref setup:
+-- - when ADC_NVREF = 1: there's only one Vref, this is Vref+
+-- - when ADC_NVREF = 2: two Vref are used, Vref+ and Vref-
+-- - when ADC_NVREF = 3: there's only one Vref, this is Vref- (not
user-friendly)
--
--
-- Notes: this file is generated, don't modify it directly...
@@ -41,6 +46,9 @@
if ADC_NVREF == 2 then
vcfg_shadow = 3 -- 0b_10 | 0b_01 => 0b_11 => one bit per VCFG bit*2
end if
+ if ADC_NVREF == 3 then
+ vcfg_shadow = 2 -- 0b_10 | 0b_00 => 0b_10 => one bit per VCFG bit*2
+ end if
if defined(ADCON0_VCFG) == true then
ADCON0_VCFG = vcfg_shadow
@@ -54,24 +62,36 @@
elsif ADC_NVREF == 2 then
ADCON1_VCFG0 = true
ADCON1_VCFG1 = true
+ elsif ADC_NVREF == 3 then
+ ADCON1_VCFG1 = true
end if
elsif defined(ADCON0_VCFG0) == true then
if ADC_NVREF == 1 then
- ADCON0_PVCFG0 = true
+ ADCON0_VCFG0 = true
elsif ADC_NVREF == 2 then
ADCON0_VCFG0 = true
ADCON0_VCFG1 = true
+ elsif ADC_NVREF == 3 then
+ ADCON0_VCFG1 = true
end if
-- Special case for PVCFG
+ -- Need to act on PVCFG and NVCFG bits
elsif defined(ADCON1_PVCFG0) == true then
- if ADC_NVREF > 0 then
+ if ADC_NVREF == 1 then
-- PVCFG = 0b_01
ADCON1_PVCFG0 = false
ADCON1_PVCFG1 = true
elsif ADC_NVREF == 2 then
+ -- PVCFG = 0b_01
+ ADCON1_PVCFG0 = false
+ ADCON1_PVCFG1 = true
-- NVCFG = 0b_01
ADCON1_NVCFG0 = false
ADCON1_NVCFG1 = true
+ elsif ADC_NVREF == 3 then
+ -- NVCFG = 0b_01
+ ADCON1_NVCFG0 = false
+ ADCON1_NVCFG1 = true
end if
else
if defined(ADC_NVREF) == true & ADC_NVREF != 0 then
@@ -107,107 +127,60 @@
-- combination
-- -----------------------------------------
-if target_chip == PIC_18F2550 | target_chip == PIC_18F4550 | target_chip
== PIC_18F4455 | target_chip == PIC_18F2455 | target_chip == PIC_18F6680 |
target_chip == PIC_18F6585 | target_chip == PIC_18F8585 | target_chip ==
PIC_18F8680 | target_chip == PIC_16F870 | target_chip == PIC_16F871 |
target_chip == PIC_16F73 | target_chip == PIC_16F74 | target_chip ==
PIC_16F77 | target_chip == PIC_16F76 | target_chip == PIC_18F4450 |
target_chip == PIC_18F2450 | target_chip == PIC_18F2553 | target_chip ==
PIC_18F4553 | target_chip == PIC_18F2458 | target_chip == PIC_18F4458 |
target_chip == PIC_18F66J93 | target_chip == PIC_18F67J93 | target_chip ==
PIC_18F86J93 | target_chip == PIC_18F87J93 | target_chip == PIC_16F767 |
target_chip == PIC_16F737 | target_chip == PIC_16F747 | target_chip ==
PIC_16F777 | target_chip == PIC_16F72 | target_chip == PIC_16F876A |
target_chip == PIC_16F874A | target_chip == PIC_16F877A | target_chip ==
PIC_16F873A | target_chip == PIC_16F716 | target_chip == PIC_18F4439 |
target_chip == PIC_18F4539 | target_chip == PIC_18F2539 | target_chip ==
PIC_18F2439 | target_chip == PIC_16F873 | target_chip == PIC_16F874 |
target_chip == PIC_16F876 | target_chip == PIC_16F877 | target_chip ==
PIC_16F872 | target_chip == PIC_16F818 | target_chip == PIC_16F819 then
+if target_chip == PIC_16F72 | target_chip == PIC_16F767 | target_chip ==
PIC_16F777 | target_chip == PIC_16F747 | target_chip == PIC_16F737 |
target_chip == PIC_16F876A | target_chip == PIC_16F873A | target_chip ==
PIC_16F877A | target_chip == PIC_16F874A | target_chip == PIC_18F2550 |
target_chip == PIC_18F4550 | target_chip == PIC_18F4455 | target_chip ==
PIC_18F2455 | target_chip == PIC_16F870 | target_chip == PIC_16F871 |
target_chip == PIC_18F4450 | target_chip == PIC_18F2450 | target_chip ==
PIC_18F6585 | target_chip == PIC_18F8680 | target_chip == PIC_18F6680 |
target_chip == PIC_18F8585 | target_chip == PIC_18F2553 | target_chip ==
PIC_18F4553 | target_chip == PIC_18F2458 | target_chip == PIC_18F4458 |
target_chip == PIC_16F73 | target_chip == PIC_16F74 | target_chip ==
PIC_16F77 | target_chip == PIC_16F76 | target_chip == PIC_16F872 |
target_chip == PIC_16F873 | target_chip == PIC_16F874 | target_chip ==
PIC_16F876 | target_chip == PIC_16F877 | target_chip == PIC_18F4539 |
target_chip == PIC_18F2539 | target_chip == PIC_18F2439 | target_chip ==
PIC_18F4439 | target_chip == PIC_18F66J93 | target_chip == PIC_18F67J93 |
target_chip == PIC_18F86J93 | target_chip == PIC_18F87J93 | target_chip ==
PIC_16F818 | target_chip == PIC_16F819 | target_chip == PIC_16F716 then
_debug "ADC channels config: dependent pins, via PCFG bits"
- procedure _adc_setup_independent() is
+ procedure _adc_setup_pins() is
pragma inline
- -- Datasheet: 39632D
- if target_chip == PIC_18F2550 | target_chip == PIC_18F2455 then
+ -- Datasheet: 39597
+ if target_chip == PIC_16F72 then
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [33] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1000, 0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100,
0b_0, 0b_0, 0b_0011, 0b_0, 0b_0, 0b_0000, 0b_0, 0b_0}
- var bit*4 no_vref = 0
- var bit*4 one_vref = 0
- var bit*4 two_vref = 0
+ const byte ADC_PCFG_MAP [18] = {0b_111, 0b_0, 0b_0, 0b_0, 0b_0,
0b_0, 0b_0, 0b_0, 0b_0, 0b_100, 0b_101, 0b_0, 0b_0, 0b_0, 0b_0, 0b_000,
0b_001, 0b_0}
+ var bit*3 no_vref = 0
+ var bit*3 one_vref = 0
+ var bit*3 two_vref = 0
if (ADC_NCHANNEL) == 0 then
asm nop
elsif (ADC_NCHANNEL) == 1 then
- pin_AN0_direction = input
+ asm nop
elsif (ADC_NCHANNEL) == 2 then
- pin_AN1_direction = input
- pin_AN0_direction = input
+ asm nop
elsif (ADC_NCHANNEL) == 3 then
- pin_AN2_direction = input
- pin_AN1_direction = input
pin_AN0_direction = input
- elsif (ADC_NCHANNEL) == 4 then
- pin_AN2_direction = input
pin_AN1_direction = input
pin_AN3_direction = input
- pin_AN0_direction = input
+ elsif (ADC_NCHANNEL) == 4 then
+ asm nop
elsif (ADC_NCHANNEL) == 5 then
- pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN1_direction = input
- pin_AN3_direction = input
- pin_AN0_direction = input
- elsif (ADC_NCHANNEL) == 6 then
pin_AN2_direction = input
- pin_AN4_direction = input
- pin_AN1_direction = input
pin_AN3_direction = input
pin_AN0_direction = input
- pin_AN8_direction = input
- elsif (ADC_NCHANNEL) == 7 then
- pin_AN2_direction = input
- pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN3_direction = input
- pin_AN0_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
- elsif (ADC_NCHANNEL) == 8 then
- pin_AN2_direction = input
- pin_AN4_direction = input
- pin_AN10_direction = input
- pin_AN1_direction = input
- pin_AN3_direction = input
- pin_AN0_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
- elsif (ADC_NCHANNEL) == 9 then
- pin_AN2_direction = input
- pin_AN4_direction = input
- pin_AN10_direction = input
- pin_AN11_direction = input
- pin_AN1_direction = input
- pin_AN3_direction = input
- pin_AN0_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
- elsif (ADC_NCHANNEL) == 10 then
- pin_AN2_direction = input
- pin_AN4_direction = input
- pin_AN10_direction = input
- pin_AN11_direction = input
- pin_AN1_direction = input
- pin_AN3_direction = input
- pin_AN12_direction = input
- pin_AN0_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
end if
end if
- -- Datasheet: 39632D
- if target_chip == PIC_18F4550 | target_chip == PIC_18F4455 then
+
+
+ -- Datasheet: 30498
+ if target_chip == PIC_16F777 | target_chip == PIC_16F747 then
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [42] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1010, 0b_0, 0b_0, 0b_1001, 0b_0, 0b_0, 0b_1000, 0b_0, 0b_0, 0b_0111,
0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_0,
0b_0011, 0b_0, 0b_0, 0b_0000, 0b_0, 0b_0}
+ const byte ADC_PCFG_MAP [45] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1010, 0b_0, 0b_0, 0b_1001, 0b_0, 0b_0, 0b_1000, 0b_0, 0b_0, 0b_0111,
0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_0,
0b_0011, 0b_0, 0b_0, 0b_0010, 0b_0, 0b_0, 0b_0000, 0b_0, 0b_0}
var bit*4 no_vref = 0
var bit*4 one_vref = 0
var bit*4 two_vref = 0
@@ -318,22 +291,35 @@
pin_AN9_direction = input
pin_AN5_direction = input
pin_AN8_direction = input
+ elsif (ADC_NCHANNEL) == 14 then
+ pin_AN2_direction = input
+ pin_AN4_direction = input
+ pin_AN10_direction = input
+ pin_AN11_direction = input
+ pin_AN1_direction = input
+ pin_AN13_direction = input
+ pin_AN7_direction = input
+ pin_AN6_direction = input
+ pin_AN3_direction = input
+ pin_AN12_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN5_direction = input
+ pin_AN8_direction = input
end if
end if
-
-
- -- Datasheet: 30491C
- if target_chip == PIC_18F8585 | target_chip == PIC_18F8680 then
+ -- Datasheet: 30498
+ if target_chip == PIC_16F767 | target_chip == PIC_16F737 then
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [51] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1010, 0b_0, 0b_0, 0b_1001, 0b_0, 0b_0, 0b_1000, 0b_0, 0b_0, 0b_0111,
0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_0,
0b_0011, 0b_0, 0b_0, 0b_0010, 0b_0, 0b_0, 0b_0001, 0b_0, 0b_0, 0b_0, 0b_0,
0b_0, 0b_0000, 0b_0, 0b_0}
+ const byte ADC_PCFG_MAP [36] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1000, 0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100,
0b_0, 0b_0, 0b_0011, 0b_0, 0b_0, 0b_0010, 0b_0, 0b_0, 0b_0000, 0b_0, 0b_0}
var bit*4 no_vref = 0
var bit*4 one_vref = 0
var bit*4 two_vref = 0
@@ -352,146 +338,270 @@
elsif (ADC_NCHANNEL) == 4 then
pin_AN2_direction = input
pin_AN1_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
elsif (ADC_NCHANNEL) == 5 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
elsif (ADC_NCHANNEL) == 6 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 7 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
- pin_AN6_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 8 then
pin_AN2_direction = input
pin_AN4_direction = input
+ pin_AN10_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN7_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
- pin_AN6_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 9 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN8_direction = input
+ pin_AN10_direction = input
+ pin_AN11_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN7_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
- pin_AN6_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 10 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
+ pin_AN10_direction = input
+ pin_AN11_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN7_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
- pin_AN6_direction = input
+ pin_AN12_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 11 then
pin_AN2_direction = input
pin_AN4_direction = input
+ pin_AN10_direction = input
+ pin_AN11_direction = input
+ pin_AN1_direction = input
+ pin_AN13_direction = input
+ pin_AN3_direction = input
+ pin_AN12_direction = input
+ pin_AN0_direction = input
pin_AN9_direction = input
pin_AN8_direction = input
- pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN7_direction = input
+ end if
+
+ end if
+
+
+
+
+ -- Datasheet: 39582
+ if target_chip == PIC_16F876A | target_chip == PIC_16F873A then
+
+
+
+ -- This array stores PCFG config bits, 3 by 3, for each number of
+ -- ADC channels, from 1 to the max:
+ -- For each 3-tuple: (no vref, 1 vref, 2 vref)
+ const byte ADC_PCFG_MAP [18] = {0b_0110, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_1111, 0b_0, 0b_0101,
0b_1101, 0b_1001, 0b_1010, 0b_1000}
+ var bit*4 no_vref = 0
+ var bit*4 one_vref = 0
+ var bit*4 two_vref = 0
+
+ if (ADC_NCHANNEL) == 0 then
+ asm nop
+ elsif (ADC_NCHANNEL) == 1 then
pin_AN0_direction = input
+ elsif (ADC_NCHANNEL) == 2 then
+ asm nop
+ elsif (ADC_NCHANNEL) == 3 then
+ pin_AN0_direction = input
+ pin_AN2_direction = input
pin_AN3_direction = input
- pin_AN10_direction = input
- pin_AN6_direction = input
- elsif (ADC_NCHANNEL) == 12 then
+ elsif (ADC_NCHANNEL) == 4 then
+ pin_AN1_direction = input
+ pin_AN0_direction = input
pin_AN2_direction = input
+ pin_AN3_direction = input
+ elsif (ADC_NCHANNEL) == 5 then
pin_AN4_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN7_direction = input
pin_AN0_direction = input
+ pin_AN2_direction = input
pin_AN3_direction = input
- pin_AN10_direction = input
- pin_AN11_direction = input
- pin_AN6_direction = input
- elsif (ADC_NCHANNEL) == 13 then
+ end if
+
+ end if
+
+
+ -- Datasheet: 39582
+ if target_chip == PIC_16F877A | target_chip == PIC_16F874A then
+
+
+
+ -- This array stores PCFG config bits, 3 by 3, for each number of
+ -- ADC channels, from 1 to the max:
+ -- For each 3-tuple: (no vref, 1 vref, 2 vref)
+ const byte ADC_PCFG_MAP [27] = {0b_0110, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_1111, 0b_0, 0b_0101,
0b_1101, 0b_0010, 0b_0011, 0b_1100, 0b_1001, 0b_1010, 0b_1011, 0b_0, 0b_0,
0b_0, 0b_0000, 0b_0001, 0b_1000}
+ var bit*4 no_vref = 0
+ var bit*4 one_vref = 0
+ var bit*4 two_vref = 0
+
+ if (ADC_NCHANNEL) == 0 then
+ asm nop
+ elsif (ADC_NCHANNEL) == 1 then
+ pin_AN0_direction = input
+ elsif (ADC_NCHANNEL) == 2 then
+ asm nop
+ elsif (ADC_NCHANNEL) == 3 then
+ pin_AN0_direction = input
pin_AN2_direction = input
+ pin_AN3_direction = input
+ elsif (ADC_NCHANNEL) == 4 then
+ pin_AN1_direction = input
+ pin_AN0_direction = input
+ pin_AN2_direction = input
+ pin_AN3_direction = input
+ elsif (ADC_NCHANNEL) == 5 then
pin_AN4_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN12_direction = input
- pin_AN7_direction = input
pin_AN0_direction = input
+ pin_AN2_direction = input
pin_AN3_direction = input
- pin_AN10_direction = input
- pin_AN11_direction = input
- pin_AN6_direction = input
- elsif (ADC_NCHANNEL) == 14 then
+ elsif (ADC_NCHANNEL) == 6 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
pin_AN1_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
pin_AN5_direction = input
- pin_AN12_direction = input
- pin_AN13_direction = input
+ elsif (ADC_NCHANNEL) == 7 then
+ asm nop
+ elsif (ADC_NCHANNEL) == 8 then
+ pin_AN4_direction = input
+ pin_AN1_direction = input
pin_AN7_direction = input
+ pin_AN6_direction = input
pin_AN0_direction = input
+ pin_AN5_direction = input
+ pin_AN2_direction = input
pin_AN3_direction = input
- pin_AN10_direction = input
- pin_AN11_direction = input
- pin_AN6_direction = input
- elsif (ADC_NCHANNEL) == 15 then
+ end if
+
+ end if
+
+
+
+
+ -- Datasheet: 39632
+ if target_chip == PIC_18F2550 | target_chip == PIC_18F2455 then
+
+
+
+ -- This array stores PCFG config bits, 3 by 3, for each number of
+ -- ADC channels, from 1 to the max:
+ -- For each 3-tuple: (no vref, 1 vref, 2 vref)
+ const byte ADC_PCFG_MAP [33] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1000, 0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100,
0b_0, 0b_0, 0b_0011, 0b_0, 0b_0, 0b_0000, 0b_0, 0b_0}
+ var bit*4 no_vref = 0
+ var bit*4 one_vref = 0
+ var bit*4 two_vref = 0
+
+ if (ADC_NCHANNEL) == 0 then
asm nop
- elsif (ADC_NCHANNEL) == 16 then
+ elsif (ADC_NCHANNEL) == 1 then
+ pin_AN0_direction = input
+ elsif (ADC_NCHANNEL) == 2 then
+ pin_AN1_direction = input
+ pin_AN0_direction = input
+ elsif (ADC_NCHANNEL) == 3 then
+ pin_AN2_direction = input
+ pin_AN1_direction = input
+ pin_AN0_direction = input
+ elsif (ADC_NCHANNEL) == 4 then
+ pin_AN2_direction = input
+ pin_AN1_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
+ elsif (ADC_NCHANNEL) == 5 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN15_direction = input
+ pin_AN1_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
+ elsif (ADC_NCHANNEL) == 6 then
+ pin_AN2_direction = input
+ pin_AN4_direction = input
+ pin_AN1_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN8_direction = input
+ elsif (ADC_NCHANNEL) == 7 then
+ pin_AN2_direction = input
+ pin_AN4_direction = input
+ pin_AN1_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
pin_AN9_direction = input
pin_AN8_direction = input
+ elsif (ADC_NCHANNEL) == 8 then
+ pin_AN2_direction = input
+ pin_AN4_direction = input
+ pin_AN10_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN12_direction = input
- pin_AN13_direction = input
- pin_AN7_direction = input
+ pin_AN3_direction = input
pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
+ elsif (ADC_NCHANNEL) == 9 then
+ pin_AN2_direction = input
+ pin_AN4_direction = input
+ pin_AN10_direction = input
+ pin_AN11_direction = input
+ pin_AN1_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
+ elsif (ADC_NCHANNEL) == 10 then
+ pin_AN2_direction = input
+ pin_AN4_direction = input
pin_AN10_direction = input
- pin_AN14_direction = input
pin_AN11_direction = input
- pin_AN6_direction = input
+ pin_AN1_direction = input
+ pin_AN3_direction = input
+ pin_AN12_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
end if
end if
- -- Datasheet: 30491C
- if target_chip == PIC_18F6680 | target_chip == PIC_18F6585 then
+ -- Datasheet: 39632
+ if target_chip == PIC_18F4550 | target_chip == PIC_18F4455 then
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [39] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1010, 0b_0, 0b_0, 0b_1001, 0b_0, 0b_0, 0b_1000, 0b_0, 0b_0, 0b_0111,
0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_0,
0b_0010, 0b_0, 0b_0}
+ const byte ADC_PCFG_MAP [42] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1010, 0b_0, 0b_0, 0b_1001, 0b_0, 0b_0, 0b_1000, 0b_0, 0b_0, 0b_0111,
0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_0,
0b_0011, 0b_0, 0b_0, 0b_0000, 0b_0, 0b_0}
var bit*4 no_vref = 0
var bit*4 one_vref = 0
var bit*4 two_vref = 0
@@ -510,84 +620,98 @@
elsif (ADC_NCHANNEL) == 4 then
pin_AN2_direction = input
pin_AN1_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
elsif (ADC_NCHANNEL) == 5 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
elsif (ADC_NCHANNEL) == 6 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN5_direction = input
elsif (ADC_NCHANNEL) == 7 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN0_direction = input
- pin_AN3_direction = input
pin_AN6_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN5_direction = input
elsif (ADC_NCHANNEL) == 8 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
pin_AN7_direction = input
- pin_AN0_direction = input
- pin_AN3_direction = input
pin_AN6_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN5_direction = input
elsif (ADC_NCHANNEL) == 9 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
pin_AN7_direction = input
- pin_AN0_direction = input
- pin_AN3_direction = input
pin_AN6_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN5_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 10 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
pin_AN7_direction = input
- pin_AN0_direction = input
- pin_AN3_direction = input
pin_AN6_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN5_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 11 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
+ pin_AN10_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
pin_AN7_direction = input
- pin_AN0_direction = input
- pin_AN3_direction = input
- pin_AN10_direction = input
pin_AN6_direction = input
+ pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN5_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 12 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN9_direction = input
- pin_AN8_direction = input
+ pin_AN10_direction = input
+ pin_AN11_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
pin_AN7_direction = input
- pin_AN0_direction = input
+ pin_AN6_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN5_direction = input
+ pin_AN8_direction = input
+ elsif (ADC_NCHANNEL) == 13 then
+ pin_AN2_direction = input
+ pin_AN4_direction = input
pin_AN10_direction = input
pin_AN11_direction = input
+ pin_AN1_direction = input
+ pin_AN7_direction = input
pin_AN6_direction = input
+ pin_AN3_direction = input
+ pin_AN12_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN5_direction = input
+ pin_AN8_direction = input
end if
end if
@@ -595,8 +719,8 @@
- -- Datasheet: 30569B
- if target_chip == PIC_16F870 then
+ -- Datasheet: 30292
+ if target_chip == PIC_16F873 | target_chip == PIC_16F876 then
@@ -634,8 +758,8 @@
end if
- -- Datasheet: 30569B
- if target_chip == PIC_16F871 then
+ -- Datasheet: 30292
+ if target_chip == PIC_16F874 | target_chip == PIC_16F877 then
@@ -693,102 +817,15 @@
- -- Datasheet: 30325B
- if target_chip == PIC_16F73 | target_chip == PIC_16F76 then
+ -- Datasheet: 30569
+ if target_chip == PIC_16F870 then
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [18] = {0b_110, 0b_0, 0b_0, 0b_0, 0b_0,
0b_0, 0b_0, 0b_0, 0b_0, 0b_100, 0b_101, 0b_0, 0b_0, 0b_0, 0b_0, 0b_000,
0b_001, 0b_0}
- var bit*3 no_vref = 0
- var bit*3 one_vref = 0
- var bit*3 two_vref = 0
-
- if (ADC_NCHANNEL) == 0 then
- asm nop
- elsif (ADC_NCHANNEL) == 1 then
- asm nop
- elsif (ADC_NCHANNEL) == 2 then
- asm nop
- elsif (ADC_NCHANNEL) == 3 then
- pin_AN0_direction = input
- pin_AN1_direction = input
- pin_AN3_direction = input
- elsif (ADC_NCHANNEL) == 4 then
- asm nop
- elsif (ADC_NCHANNEL) == 5 then
- pin_AN4_direction = input
- pin_AN2_direction = input
- pin_AN3_direction = input
- pin_AN0_direction = input
- pin_AN1_direction = input
- end if
-
- end if
-
-
- -- Datasheet: 30325B
- if target_chip == PIC_16F74 | target_chip == PIC_16F77 then
-
-
-
- -- This array stores PCFG config bits, 3 by 3, for each number of
- -- ADC channels, from 1 to the max:
- -- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [27] = {0b_110, 0b_0, 0b_0, 0b_0, 0b_0,
0b_0, 0b_0, 0b_0, 0b_0, 0b_100, 0b_101, 0b_0, 0b_0, 0b_0, 0b_0, 0b_010,
0b_011, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_000, 0b_001, 0b_0}
- var bit*3 no_vref = 0
- var bit*3 one_vref = 0
- var bit*3 two_vref = 0
-
- if (ADC_NCHANNEL) == 0 then
- asm nop
- elsif (ADC_NCHANNEL) == 1 then
- asm nop
- elsif (ADC_NCHANNEL) == 2 then
- asm nop
- elsif (ADC_NCHANNEL) == 3 then
- pin_AN0_direction = input
- pin_AN1_direction = input
- pin_AN3_direction = input
- elsif (ADC_NCHANNEL) == 4 then
- asm nop
- elsif (ADC_NCHANNEL) == 5 then
- pin_AN4_direction = input
- pin_AN2_direction = input
- pin_AN0_direction = input
- pin_AN1_direction = input
- pin_AN3_direction = input
- elsif (ADC_NCHANNEL) == 6 then
- asm nop
- elsif (ADC_NCHANNEL) == 7 then
- asm nop
- elsif (ADC_NCHANNEL) == 8 then
- pin_AN7_direction = input
- pin_AN5_direction = input
- pin_AN6_direction = input
- pin_AN4_direction = input
- pin_AN2_direction = input
- pin_AN3_direction = input
- pin_AN0_direction = input
- pin_AN1_direction = input
- end if
-
- end if
-
-
-
-
- -- Datasheet: 39582B
- if target_chip == PIC_16F876A | target_chip == PIC_16F873A then
-
-
-
- -- This array stores PCFG config bits, 3 by 3, for each number of
- -- ADC channels, from 1 to the max:
- -- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [18] = {0b_0110, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_1111, 0b_0, 0b_0101,
0b_1101, 0b_1001, 0b_1010, 0b_1000}
+ const byte ADC_PCFG_MAP [18] = {0b_0110, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0100, 0b_0101, 0b_1111, 0b_0, 0b_0,
0b_1101, 0b_1001, 0b_1010, 0b_1000}
var bit*4 no_vref = 0
var bit*4 one_vref = 0
var bit*4 two_vref = 0
@@ -804,14 +841,14 @@
pin_AN2_direction = input
pin_AN3_direction = input
elsif (ADC_NCHANNEL) == 4 then
- pin_AN1_direction = input
pin_AN0_direction = input
+ pin_AN1_direction = input
pin_AN2_direction = input
pin_AN3_direction = input
elsif (ADC_NCHANNEL) == 5 then
pin_AN4_direction = input
- pin_AN1_direction = input
pin_AN0_direction = input
+ pin_AN1_direction = input
pin_AN2_direction = input
pin_AN3_direction = input
end if
@@ -819,15 +856,15 @@
end if
- -- Datasheet: 39582B
- if target_chip == PIC_16F874A | target_chip == PIC_16F877A then
+ -- Datasheet: 30569
+ if target_chip == PIC_16F871 then
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [27] = {0b_0110, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_1111, 0b_0, 0b_0101,
0b_1101, 0b_0010, 0b_0011, 0b_1100, 0b_1001, 0b_1010, 0b_1011, 0b_0, 0b_0,
0b_0, 0b_0000, 0b_0001, 0b_1000}
+ const byte ADC_PCFG_MAP [27] = {0b_0110, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0100, 0b_0101, 0b_1111, 0b_0, 0b_0,
0b_1101, 0b_0010, 0b_0011, 0b_1100, 0b_1001, 0b_1010, 0b_1011, 0b_0, 0b_0,
0b_0, 0b_0000, 0b_0001, 0b_1000}
var bit*4 no_vref = 0
var bit*4 one_vref = 0
var bit*4 two_vref = 0
@@ -843,32 +880,32 @@
pin_AN2_direction = input
pin_AN3_direction = input
elsif (ADC_NCHANNEL) == 4 then
- pin_AN1_direction = input
pin_AN0_direction = input
+ pin_AN1_direction = input
pin_AN2_direction = input
pin_AN3_direction = input
elsif (ADC_NCHANNEL) == 5 then
pin_AN4_direction = input
- pin_AN1_direction = input
pin_AN0_direction = input
+ pin_AN1_direction = input
pin_AN2_direction = input
pin_AN3_direction = input
elsif (ADC_NCHANNEL) == 6 then
- pin_AN2_direction = input
+ pin_AN5_direction = input
pin_AN4_direction = input
- pin_AN1_direction = input
+ pin_AN2_direction = input
pin_AN3_direction = input
pin_AN0_direction = input
- pin_AN5_direction = input
+ pin_AN1_direction = input
elsif (ADC_NCHANNEL) == 7 then
asm nop
elsif (ADC_NCHANNEL) == 8 then
- pin_AN4_direction = input
- pin_AN1_direction = input
pin_AN7_direction = input
+ pin_AN5_direction = input
pin_AN6_direction = input
+ pin_AN4_direction = input
pin_AN0_direction = input
- pin_AN5_direction = input
+ pin_AN1_direction = input
pin_AN2_direction = input
pin_AN3_direction = input
end if
@@ -878,15 +915,15 @@
- -- Datasheet: 39948A
- if target_chip == PIC_18F66J93 | target_chip == PIC_18F67J93 |
target_chip == PIC_18F86J93 | target_chip == PIC_18F87J93 then
+ -- Datasheet: 39760
+ if target_chip == PIC_18F2450 then
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [39] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1010, 0b_0, 0b_0, 0b_1001, 0b_0, 0b_0, 0b_1000, 0b_0, 0b_0, 0b_0111,
0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100, 0b_0, 0b_0,
0b_0000, 0b_0, 0b_0}
+ const byte ADC_PCFG_MAP [33] = {0b_1111, 0b_0, 0b_0, 0b_1110,
0b_0, 0b_0, 0b_1101, 0b_0, 0b_0, 0b_1100, 0b_0, 0b_0, 0b_1011, 0b_0, 0b_0,
0b_1000, 0b_0, 0b_0, 0b_0110, 0b_0, 0b_0, 0b_0101, 0b_0, 0b_0, 0b_0100,
0b_0, 0b_0, 0b_0011, 0b_0, 0b_0, 0b_0000, 0b_0, 0b_0}
var bit*4 no_vref = 0
var bit*4 one_vref = 0
var bit*4 two_vref = 0
@@ -905,100 +942,73 @@
elsif (ADC_NCHANNEL) == 4 then
pin_AN2_direction = input
pin_AN1_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
elsif (ADC_NCHANNEL) == 5 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
elsif (ADC_NCHANNEL) == 6 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
+ pin_AN0_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 7 then
pin_AN2_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
- pin_AN5_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
- pin_AN6_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 8 then
pin_AN2_direction = input
pin_AN4_direction = input
+ pin_AN10_direction = input
pin_AN1_direction = input
- pin_AN7_direction = input
- pin_AN5_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
- pin_AN6_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 9 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN8_direction = input
+ pin_AN10_direction = input
+ pin_AN11_direction = input
pin_AN1_direction = input
- pin_AN7_direction = input
- pin_AN5_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
- pin_AN6_direction = input
+ pin_AN0_direction = input
+ pin_AN9_direction = input
+ pin_AN8_direction = input
elsif (ADC_NCHANNEL) == 10 then
pin_AN2_direction = input
pin_AN4_direction = input
- pin_AN8_direction = input
+ pin_AN10_direction = input
+ pin_AN11_direction = input
pin_AN1_direction = input
- pin_AN9_direction = input
- pin_AN7_direction = input
- pin_AN5_direction = input
- pin_AN0_direction = input
pin_AN3_direction = input
- pin_AN6_direction = input
- elsif (ADC_NCHANNEL) == 11 then
- pin_AN2_direction = input
- pin_AN4_direction = input
- pin_AN8_direction = input
- pin_AN1_direction = input
- pin_AN9_direction = input
- pin_AN7_direction = input
- pin_AN5_direction = input
+ pin_AN12_direction = input
pin_AN0_direction = input
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/include/peripheral/adc/adc_clock.jal Thu Aug 20 22:51:43 2009
+++ /trunk/include/peripheral/adc/adc_clock.jal Fri Mar 12 12:06:34 2010
@@ -48,6 +48,7 @@
procedure _adc_init_clock() is
+ pragma inline
-- Seb: selecting the appropriate clock bits
-- is a real nightmare, yet critical.
-- Strictly speaking, all PICs don't have the same
=======================================
--- /trunk/tools/adc/adc_channels.jal.tmpl Thu Mar 11 23:13:18 2010
+++ /trunk/tools/adc/adc_channels.jal.tmpl Fri Mar 12 12:06:34 2010
@@ -22,6 +22,11 @@
-- 3. the number of channels is set using ANS bits (18F and non-18F)
-- => same as case 2., channels can be configured independently
-- Vref+/Vref- are configured using VCFG bits.
+-- --
+-- About Vref setup:
+-- - when ADC_NVREF = 1: there's only one Vref, this is Vref+
+-- - when ADC_NVREF = 2: two Vref are used, Vref+ and Vref-
+-- - when ADC_NVREF = 3: there's only one Vref, this is Vref- (not
user-friendly)
--
--
-- Notes: this file is generated, don't modify it directly...
@@ -145,7 +150,7 @@
#def pcfg_combination
- procedure _adc_setup_independent() is
+ procedure _adc_setup_pins() is
pragma inline
#set bydsref = {}
#silent [bydsref.setdefault($pic_ds[p],[]).append(p) for p in
$pcfg_combination_pics]
@@ -518,7 +523,7 @@
else
-- no exception here: ANSx corresponds to analog pin n°x
- #for i in range(23)
+ #for i in range(28)
if defined(JANSEL_ANS$i) == true then
alias ADC_JANSEL_ANS$i is JANSEL_ANS$i
end if
@@ -601,6 +606,9 @@
if ADC_NVREF == 2 then
vcfg_shadow = 3 -- 0b_10 | 0b_01 => 0b_11 => one bit per VCFG bit*2
end if
+ if ADC_NVREF == 3 then
+ vcfg_shadow = 2 -- 0b_10 | 0b_00 => 0b_10 => one bit per VCFG bit*2
+ end if
if defined(ADCON0_VCFG) == true then
ADCON0_VCFG = vcfg_shadow
@@ -614,24 +622,36 @@
elsif ADC_NVREF == 2 then
ADCON1_VCFG0 = true
ADCON1_VCFG1 = true
+ elsif ADC_NVREF == 3 then
+ ADCON1_VCFG1 = true
end if
elsif defined(ADCON0_VCFG0) == true then
if ADC_NVREF == 1 then
- ADCON0_PVCFG0 = true
+ ADCON0_VCFG0 = true
elsif ADC_NVREF == 2 then
ADCON0_VCFG0 = true
ADCON0_VCFG1 = true
+ elsif ADC_NVREF == 3 then
+ ADCON0_VCFG1 = true
end if
-- Special case for PVCFG
+ -- Need to act on PVCFG and NVCFG bits
elsif defined(ADCON1_PVCFG0) == true then
- if ADC_NVREF > 0 then
+ if ADC_NVREF == 1 then
-- PVCFG = 0b_01
ADCON1_PVCFG0 = false
ADCON1_PVCFG1 = true
elsif ADC_NVREF == 2 then
+ -- PVCFG = 0b_01
+ ADCON1_PVCFG0 = false
+ ADCON1_PVCFG1 = true
-- NVCFG = 0b_01
ADCON1_NVCFG0 = false
ADCON1_NVCFG1 = true
+ elsif ADC_NVREF == 3 then
+ -- NVCFG = 0b_01
+ ADCON1_NVCFG0 = false
+ ADCON1_NVCFG1 = true
end if
else
if defined(ADC_NVREF) == true & ADC_NVREF != 0 then
@@ -697,11 +717,9 @@
$pcfg_combination
- -- Normalize procedure names for setup
- alias _adc_setup_pins is _adc_setup_independent
-- declare dummy procedure for normalization. Note Vref setup, due to
some jalv2 contraints
-- (like defining a constant but assigning its definitive value later),
Vref setup is done
- -- while discovering/setting up ADC pins. See comment within
_adc_setup_independent()
+ -- while discovering/setting up ADC pins. See comment within
_adc_setup_pins() for dependent pins
procedure _adc_vref() is
end procedure
@@ -719,8 +737,6 @@
$pcfg_18f
$select_vref_proc
- -- Normalize procedure names for setup
- procedure _adc_setup_pins is _adc_setup_independent
-- --------------------------------------------
-- THIRD CASE:
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.