Revision: 1835
Author: sebastien.lelong
Date: Thu Mar 25 07:18:10 2010
Log: remove normalization step for 16f722 & friends exceptions, as now handled in device files. Also simplify by removing ADC_JANSEL_ANSx layer, to directly use JANSEL_ANSx
http://code.google.com/p/jallib/source/detail?r=1835

Modified:
 /trunk/include/peripheral/adc/adc_channels.jal
 /trunk/tools/adc/adc_channels.jal.tmpl

=======================================
--- /trunk/include/peripheral/adc/adc_channels.jal      Fri Mar 12 12:06:34 2010
+++ /trunk/include/peripheral/adc/adc_channels.jal      Thu Mar 25 07:18:10 2010
@@ -127,44 +127,118 @@
 --    combination
 -- -----------------------------------------

-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 +if target_chip == PIC_18F66J93 | target_chip == PIC_18F67J93 | target_chip == PIC_18F86J93 | target_chip == PIC_18F87J93 | target_chip == PIC_16F767 | target_chip == PIC_16F777 | target_chip == PIC_16F747 | target_chip == PIC_16F737 | 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_18F4539 | target_chip == PIC_18F2539 | target_chip == PIC_18F2439 | target_chip == PIC_18F4439 | target_chip == PIC_16F873 | target_chip == PIC_16F874 | target_chip == PIC_16F876 | target_chip == PIC_16F877 | target_chip == PIC_16F872 | target_chip == PIC_16F72 | 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_16F818 | target_chip == PIC_16F819 | target_chip == PIC_16F716 then
    _debug "ADC channels config: dependent pins, via PCFG bits"

    procedure _adc_setup_pins() is
       pragma inline


-      -- Datasheet: 39597
-      if target_chip == PIC_16F72 then
+      -- Datasheet: 39948
+ if target_chip == PIC_18F66J93 | target_chip == PIC_18F67J93 | target_chip == PIC_18F86J93 | target_chip == PIC_18F87J93 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_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
+ 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}
+         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
-            asm nop
+            pin_AN0_direction = input
          elsif (ADC_NCHANNEL) == 2 then
-            asm nop
+            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_AN0_direction = input
             pin_AN3_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_AN0_direction = input
+            pin_AN3_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
+         elsif (ADC_NCHANNEL) == 7 then
+            pin_AN2_direction = input
+            pin_AN4_direction = input
+            pin_AN6_direction = input
+            pin_AN1_direction = input
+            pin_AN5_direction = input
             pin_AN0_direction = input
+            pin_AN3_direction = input
+         elsif (ADC_NCHANNEL) == 8 then
+            pin_AN2_direction = input
+            pin_AN4_direction = input
+            pin_AN6_direction = input
             pin_AN1_direction = input
+            pin_AN7_direction = input
+            pin_AN5_direction = input
+            pin_AN0_direction = input
+            pin_AN3_direction = input
+         elsif (ADC_NCHANNEL) == 9 then
+            pin_AN2_direction = input
+            pin_AN4_direction = input
+            pin_AN6_direction = input
+            pin_AN1_direction = input
+            pin_AN7_direction = input
+            pin_AN5_direction = input
+            pin_AN0_direction = input
+            pin_AN3_direction = input
+            pin_AN8_direction = input
+         elsif (ADC_NCHANNEL) == 10 then
+            pin_AN2_direction = input
+            pin_AN4_direction = input
+            pin_AN6_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_AN8_direction = input
+         elsif (ADC_NCHANNEL) == 11 then
+            pin_AN2_direction = input
+            pin_AN4_direction = input
+            pin_AN6_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_AN10_direction = input
+            pin_AN8_direction = input
+         elsif (ADC_NCHANNEL) == 12 then
+            pin_AN2_direction = input
+            pin_AN4_direction = input
+            pin_AN6_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_AN10_direction = input
+            pin_AN11_direction = input
+            pin_AN8_direction = input
          end if

       end if
@@ -172,6 +246,103 @@



+      -- 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 [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
+
+         if (ADC_NCHANNEL) == 0 then
+            asm nop
+         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_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
+         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
+         end if
+
+      end if
+
+
       -- Datasheet: 30498
       if target_chip == PIC_16F777 | target_chip == PIC_16F747 then

@@ -297,8 +468,8 @@
             pin_AN10_direction = input
             pin_AN11_direction = input
             pin_AN1_direction = input
-            pin_AN13_direction = input
             pin_AN7_direction = input
+            pin_AN13_direction = input
             pin_AN6_direction = input
             pin_AN3_direction = input
             pin_AN12_direction = input
@@ -311,15 +482,17 @@
       end if


-      -- Datasheet: 30498
-      if target_chip == PIC_16F767 | target_chip == PIC_16F737 then
+
+
+      -- Datasheet: 39887
+      if target_chip == PIC_18F2553 | target_chip == PIC_18F2458 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 [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} + 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
@@ -391,34 +564,20 @@
             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
          end if

       end if


-
-
-      -- Datasheet: 39582
-      if target_chip == PIC_16F876A | target_chip == PIC_16F873A then
+      -- Datasheet: 39887
+      if target_chip == PIC_18F4553 | target_chip == PIC_18F4458 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 [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
@@ -428,79 +587,107 @@
          elsif (ADC_NCHANNEL) == 1 then
             pin_AN0_direction = input
          elsif (ADC_NCHANNEL) == 2 then
-            asm nop
-         elsif (ADC_NCHANNEL) == 3 then
+            pin_AN1_direction = input
             pin_AN0_direction = input
+         elsif (ADC_NCHANNEL) == 3 then
             pin_AN2_direction = input
-            pin_AN3_direction = input
-         elsif (ADC_NCHANNEL) == 4 then
             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_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
-         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_AN5_direction = input
+         elsif (ADC_NCHANNEL) == 7 then
             pin_AN2_direction = input
-            pin_AN3_direction = input
-         elsif (ADC_NCHANNEL) == 4 then
+            pin_AN4_direction = input
             pin_AN1_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_AN7_direction = input
+            pin_AN6_direction = input
             pin_AN3_direction = input
-         elsif (ADC_NCHANNEL) == 5 then
+            pin_AN0_direction = input
+            pin_AN5_direction = input
+         elsif (ADC_NCHANNEL) == 9 then
+            pin_AN2_direction = input
             pin_AN4_direction = input
             pin_AN1_direction = input
+            pin_AN7_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_AN1_direction = input
+            pin_AN7_direction = input
+            pin_AN6_direction = input
             pin_AN3_direction = input
-         elsif (ADC_NCHANNEL) == 6 then
+            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_AN10_direction = input
             pin_AN1_direction = input
+            pin_AN7_direction = input
+            pin_AN6_direction = input
             pin_AN3_direction = input
             pin_AN0_direction = input
+            pin_AN9_direction = input
             pin_AN5_direction = input
-         elsif (ADC_NCHANNEL) == 7 then
-            asm nop
-         elsif (ADC_NCHANNEL) == 8 then
+            pin_AN8_direction = input
+         elsif (ADC_NCHANNEL) == 12 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_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
@@ -719,15 +906,15 @@



-      -- Datasheet: 30292
-      if target_chip == PIC_16F873 | target_chip == PIC_16F876 then
+      -- Datasheet: 30491
+      if target_chip == PIC_18F8680 | target_chip == PIC_18F8585 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_0101, 0b_1111, 0b_0, 0b_0, 0b_1101, 0b_1001, 0b_1010, 0b_1000} + 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}
          var bit*4 no_vref = 0
          var bit*4 one_vref = 0
          var bit*4 two_vref = 0
@@ -737,36 +924,155 @@
          elsif (ADC_NCHANNEL) == 1 then
             pin_AN0_direction = input
          elsif (ADC_NCHANNEL) == 2 then
-            asm nop
+            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_AN0_direction = input
             pin_AN3_direction = input
-         elsif (ADC_NCHANNEL) == 4 then
+         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
+         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
+         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
-         elsif (ADC_NCHANNEL) == 5 then
+            pin_AN6_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
+         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
+         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
+         elsif (ADC_NCHANNEL) == 11 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_AN10_direction = input
+            pin_AN6_direction = input
+         elsif (ADC_NCHANNEL) == 12 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_AN10_direction = input
+            pin_AN11_direction = input
+            pin_AN6_direction = input
+         elsif (ADC_NCHANNEL) == 13 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_AN12_direction = input
+            pin_AN7_direction = input
+            pin_AN0_direction = input
+            pin_AN3_direction = input
+            pin_AN10_direction = input
+            pin_AN11_direction = input
+            pin_AN6_direction = input
+         elsif (ADC_NCHANNEL) == 14 then
+            pin_AN2_direction = input
+            pin_AN4_direction = input
+            pin_AN13_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_AN3_direction = input
+            pin_AN10_direction = input
+            pin_AN11_direction = input
+            pin_AN6_direction = input
+         elsif (ADC_NCHANNEL) == 15 then
+            asm nop
+         elsif (ADC_NCHANNEL) == 16 then
+            pin_AN2_direction = input
+            pin_AN4_direction = input
+            pin_AN13_direction = input
+            pin_AN15_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_AN3_direction = input
+            pin_AN10_direction = input
+            pin_AN14_direction = input
+            pin_AN11_direction = input
+            pin_AN6_direction = input
          end if

       end if


-      -- Datasheet: 30292
-      if target_chip == PIC_16F874 | target_chip == PIC_16F877 then
+      -- Datasheet: 30491
+      if target_chip == PIC_18F6585 | target_chip == PIC_18F6680 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_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} + 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}
          var bit*4 no_vref = 0
          var bit*4 one_vref = 0
          var bit*4 two_vref = 0
@@ -776,40 +1082,93 @@
          elsif (ADC_NCHANNEL) == 1 then
             pin_AN0_direction = input
          elsif (ADC_NCHANNEL) == 2 then
-            asm nop
-         elsif (ADC_NCHANNEL) == 3 then
+            pin_AN1_direction = input
             pin_AN0_direction = input
+         elsif (ADC_NCHANNEL) == 3 then
             pin_AN2_direction = input
-            pin_AN3_direction = input
-         elsif (ADC_NCHANNEL) == 4 then
-            pin_AN0_direction = input
             pin_AN1_direction = input
+            pin_AN0_direction = input
+         elsif (ADC_NCHANNEL) == 4 then
             pin_AN2_direction = input
+            pin_AN1_direction = input
+            pin_AN0_direction = input
             pin_AN3_direction = input
          elsif (ADC_NCHANNEL) == 5 then
+            pin_AN2_direction = input
             pin_AN4_direction = input
-            pin_AN0_direction = input
             pin_AN1_direction = input
-            pin_AN2_direction = input
+            pin_AN0_direction = input
             pin_AN3_direction = input
          elsif (ADC_NCHANNEL) == 6 then
-            pin_AN5_direction = input
-            pin_AN4_direction = input
             pin_AN2_direction = input
-            pin_AN3_direction = input
-            pin_AN0_direction = input
+            pin_AN4_direction = input
             pin_AN1_direction = input
+            pin_AN5_direction = input
+            pin_AN0_direction = input
+            pin_AN3_direction = input
          elsif (ADC_NCHANNEL) == 7 then
-            asm nop
+            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
          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
+         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
+         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
+         elsif (ADC_NCHANNEL) == 11 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_AN10_direction = input
+            pin_AN6_direction = input
+         elsif (ADC_NCHANNEL) == 12 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_AN10_direction = input
+            pin_AN11_direction = input
+            pin_AN6_direction = input
          end if

       end if
@@ -1126,15 +1485,15 @@



-      -- Datasheet: 39887
-      if target_chip == PIC_18F2553 | target_chip == PIC_18F2458 then
+      -- 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 [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} + 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
@@ -1144,82 +1503,36 @@
          elsif (ADC_NCHANNEL) == 1 then
             pin_AN0_direction = input
          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) == 5 then
-            pin_AN2_direction = input
-            pin_AN4_direction = input
+         elsif (ADC_NCHANNEL) == 4 then
             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
+         elsif (ADC_NCHANNEL) == 5 then
             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: 39887
-      if target_chip == PIC_18F4553 | target_chip == PIC_18F4458 then
+      -- 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 [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 [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
@@ -1229,107 +1542,40 @@
          elsif (ADC_NCHANNEL) == 1 then
             pin_AN0_direction = input
          elsif (ADC_NCHANNEL) == 2 then
-            pin_AN1_direction = input
-            pin_AN0_direction = input
+            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
-         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_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_AN5_direction = input
-         elsif (ADC_NCHANNEL) == 7 then
+         elsif (ADC_NCHANNEL) == 6 then
             pin_AN2_direction = input
             pin_AN4_direction = input
             pin_AN1_direction = input
-            pin_AN6_direction = input
             pin_AN3_direction = input
             pin_AN0_direction = input
             pin_AN5_direction = input
+         elsif (ADC_NCHANNEL) == 7 then
+            asm nop
          elsif (ADC_NCHANNEL) == 8 then
-            pin_AN2_direction = input
             pin_AN4_direction = input
             pin_AN1_direction = input
             pin_AN7_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_AN1_direction = input
-            pin_AN7_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_AN1_direction = input
-            pin_AN7_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_AN10_direction = input
-            pin_AN1_direction = input
-            pin_AN7_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_AN10_direction = input
-            pin_AN11_direction = input
-            pin_AN1_direction = input
-            pin_AN7_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
@@ -1424,15 +1670,15 @@



-      -- Datasheet: 30221
-      if target_chip == PIC_16F872 then
+      -- Datasheet: 30485
+      if target_chip == PIC_18F2539 | target_chip == PIC_18F2439 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_0101, 0b_1111, 0b_0, 0b_0, 0b_1101, 0b_1001, 0b_1010, 0b_1000} + const byte ADC_PCFG_MAP [18] = {0b_0110, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0100, 0b_0101, 0b_1110, 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
@@ -1440,7 +1686,7 @@
          if (ADC_NCHANNEL) == 0 then
             asm nop
          elsif (ADC_NCHANNEL) == 1 then
-            pin_AN0_direction = input
+            asm nop
          elsif (ADC_NCHANNEL) == 2 then
             asm nop
          elsif (ADC_NCHANNEL) == 3 then
@@ -1448,14 +1694,14 @@
             pin_AN2_direction = input
             pin_AN3_direction = input
          elsif (ADC_NCHANNEL) == 4 then
-            pin_AN0_direction = input
             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_AN0_direction = input
             pin_AN1_direction = input
+            pin_AN0_direction = input
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/tools/adc/adc_channels.jal.tmpl      Fri Mar 12 12:06:34 2010
+++ /trunk/tools/adc/adc_channels.jal.tmpl      Thu Mar 25 07:18:10 2010
@@ -484,51 +484,10 @@
    -- (/!\, true/false logic is inverted compared to PCFGx bits)

-- Some exceptions have been reported related to 16f72X family. These devises - -- have gaps within their analog pins, but ANSx bits are continued. For instance, + -- have gaps within their analog pins, but ANSx bits are contigous. For instance, -- for 16f722, JANSEL_ANS5 should refer to analog pin AN5, but it does not exist ! - -- We need to put some more exceptions here, hoping there won't be much more. If so, - -- these would have to be dealt an in external file people could easily enrich.
-   -- Anyway... here we go !
+   -- These exceptions are handled in device files.
    -- Guilty PICs: 16F722, 16F723, 16F724, 16F726, 16F727 + LF versions
-   -- Here's how ANSx bits are mapped to analog pins:
-   ## stores JANSEL_ANSx <=> AN pin number
- ## 16F72X_map = {0:0, 1:1, 2:2, 3:3, 4:5, 6:12, 7:10, 8:8, 9:9, 10:11, 11:13, 20:5, 21:6, 22:7}
-   ## Maybe this should be in an external python lib file...
-
- if target_chip == PIC_16F722 | target_chip == PIC_16F723 | target_chip == PIC_16F724 | target_chip == PIC_16F726 | target_chip == PIC_16F727 | - target_chip == PIC_16LF722 | target_chip == PIC_16LF723 | target_chip == PIC_16LF724 | target_chip == PIC_16LF726 | target_chip == PIC_16LF727 then
-
-      ## always exists in all 16F72X family
-      alias ADC_JANSEL_ANS0  is JANSEL_ANS0
-      alias ADC_JANSEL_ANS1  is JANSEL_ANS1
-      alias ADC_JANSEL_ANS2  is JANSEL_ANS2
-      alias ADC_JANSEL_ANS3  is JANSEL_ANS3
-      alias ADC_JANSEL_ANS4  is JANSEL_ANS5
-      alias ADC_JANSEL_ANS12 is JANSEL_ANS6
-      alias ADC_JANSEL_ANS10 is JANSEL_ANS7
-      alias ADC_JANSEL_ANS8  is JANSEL_ANS8
-      alias ADC_JANSEL_ANS9  is JANSEL_ANS9
-      alias ADC_JANSEL_ANS11 is JANSEL_ANS10
-      alias ADC_JANSEL_ANS13 is JANSEL_ANS11
-
-
-
-
-      ## only for these
- if target_chip == PIC_16F724 | target_chip == PIC_16F727 | target_chip == PIC_16LF724 | target_chip == PIC_16LF727 then
-         alias ADC_JANSEL_ANS5 is JANSEL_ANS20
-           alias ADC_JANSEL_ANS6 is JANSEL_ANS21
-           alias ADC_JANSEL_ANS7 is JANSEL_ANS22
-      end if
-
-   else
-      -- no exception here: ANSx corresponds to analog pin n°x
-      #for i in range(28)
-         if defined(JANSEL_ANS$i) == true then
-            alias ADC_JANSEL_ANS$i is JANSEL_ANS$i
-         end if
-      #end for
-   end if

-- Contrary to independent ADC pins managed by PCFG bits, choosing the number -- of ADC channels can only be done with set_analog_pin()/set_digital_pin().
@@ -545,14 +504,14 @@
    --     - set_analog_pin(4) will do the same for AN4
    procedure set_analog_pin(byte in an_pin_num) is
       #set conds = []
-      #for i in range(23)
-      if defined(ADC_JANSEL_ANS$i) == true then
+      #for i in range(28)
+      if defined(JANSEL_ANS$i) == true then
          if an_pin_num == $i then
-            ADC_JANSEL_ANS$i = true
+            JANSEL_ANS$i = true
             pin_AN${i}_direction = input
          end if
       end if
-      #silent conds.append("defined(ADC_JANSEL_ANS%s) == false" % $i)
+      #silent conds.append("defined(JANSEL_ANS%s) == false" % $i)
       #end for
       #set finalcond = " & ".join(conds)
       if $finalcond then
@@ -573,9 +532,9 @@
    -- Note: the pin direction is not modified
    procedure set_digital_pin(byte in an_pin_num) is
       #for i in range(23)
-      if defined(ADC_JANSEL_ANS$i) == true then
+      if defined(JANSEL_ANS$i) == true then
          if an_pin_num == $i then
-            ADC_JANSEL_ANS$i = false
+            JANSEL_ANS$i = false
          end if
       end if
       #end for

--
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.

Reply via email to