Revision: 1396
Author: sebastien.lelong
Date: Fri Oct 16 13:44:30 2009
Log: new ADC libs + adc_pcfg. New supported PICs: 18F2450, 18F4450,  
18F2455, 18F2550, 18F4455, 18F4550
http://code.google.com/p/jallib/source/detail?r=1396

Modified:
  /trunk/include/peripheral/adc/adc_channels.jal
  /trunk/tools/adc/adc_pcfg.py

=======================================
--- /trunk/include/peripheral/adc/adc_channels.jal      Sun Aug  9 01:29:38 2009
+++ /trunk/include/peripheral/adc/adc_channels.jal      Fri Oct 16 13:44:30 2009
@@ -109,7 +109,218 @@
  --    combination
  -- -----------------------------------------

-if 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_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_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_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
+
+
+   -- Datasheet: 39632D
+   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) == 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
+         end if
+
+   end if
+
+
+   -- Datasheet: 39632D
+   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 [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
+
+         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_AN5_direction = input
+         elsif (ADC_NCHANNEL) == 7 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) == 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
+
+


     -- Datasheet: 30491C
@@ -950,6 +1161,104 @@
              pin_AN1_direction = input
           end if

+   end if
+
+
+
+
+   -- Datasheet: 30292C
+   if target_chip == PIC_16F873 | target_chip == PIC_16F876 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}
+         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_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_AN0_direction = input
+            pin_AN1_direction = input
+            pin_AN2_direction = input
+            pin_AN3_direction = input
+         end if
+
+   end if
+
+
+   -- Datasheet: 30292C
+   if target_chip == PIC_16F874 | target_chip == PIC_16F877 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}
+         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_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_AN0_direction = input
+            pin_AN1_direction = input
+            pin_AN2_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_AN1_direction = input
+         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_AN0_direction = input
+            pin_AN1_direction = input
+            pin_AN2_direction = input
+            pin_AN3_direction = input
+         end if
+
     end if


@@ -1088,15 +1397,15 @@



-   -- Datasheet: 30292C
-   if target_chip == PIC_16F873 | target_chip == PIC_16F876 then
+   -- Datasheet: 30485A
+   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
@@ -1104,7 +1413,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
@@ -1112,14 +1421,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
              pin_AN2_direction = input
              pin_AN3_direction = input
           end if
@@ -1127,15 +1436,15 @@
     end if


-   -- Datasheet: 30292C
-   if target_chip == PIC_16F874 | target_chip == PIC_16F877 then
+   -- Datasheet: 30485A
+   if target_chip == PIC_18F4439 | target_chip == PIC_18F4539 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 [27] = {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_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
@@ -1143,7 +1452,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
@@ -1151,32 +1460,32 @@
              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
              pin_AN2_direction = input
              pin_AN3_direction = input
           elsif (ADC_NCHANNEL) == 6 then
-            pin_AN5_direction = input
-            pin_AN4_direction = input
              pin_AN2_direction = input
+            pin_AN4_direction = input
+            pin_AN1_direction = input
              pin_AN3_direction = input
              pin_AN0_direction = input
-            pin_AN1_direction = input
+            pin_AN5_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_AN1_direction = input
+            pin_AN5_direction = input
              pin_AN2_direction = input
              pin_AN3_direction = input
           end if
@@ -1186,15 +1495,15 @@



-   -- Datasheet: 30485A
-   if target_chip == PIC_18F2539 | target_chip == PIC_18F2439 then
+   -- Datasheet: 39760D
+   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 [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}
+         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
@@ -1202,38 +1511,84 @@
           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_AN3_direction = input
-         elsif (ADC_NCHANNEL) == 4 then
+            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
-         elsif (ADC_NCHANNEL) == 5 then
+            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: 30485A
-   if target_chip == PIC_18F4439 | target_chip == PIC_18F4539 then
+   -- Datasheet: 39760D
+   if target_chip == PIC_18F4450 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_0, 0b_0,  
0b_0, 0b_0, 0b_0, 0b_0, 0b_0100, 0b_0101, 0b_1110, 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 [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
@@ -1241,24 +1596,25 @@
           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
-         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_AN0_direction = input
-            pin_AN2_direction = input
              pin_AN3_direction = input
+            pin_AN0_direction = input
           elsif (ADC_NCHANNEL) == 6 then
              pin_AN2_direction = input
              pin_AN4_direction = input
@@ -1267,16 +1623,82 @@
              pin_AN0_direction = input
              pin_AN5_direction = input
           elsif (ADC_NCHANNEL) == 7 then
-                   asm nop
+            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) == 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
=======================================
--- /trunk/tools/adc/adc_pcfg.py        Tue Jul 28 23:00:14 2009
+++ /trunk/tools/adc/adc_pcfg.py        Fri Oct 16 13:44:30 2009
@@ -1459,4 +1459,432 @@
                        'AN0/RA0' : 'D',
          },
   },
-}
+ '39632D': {
+         # same config for '0001' and '0010', only keep one config
+         # else will produce error in ADC lib generation
+         '0000': {
+                       'AN12/RB0': 'A',
+                       'AN11/RB4': 'A',
+                       'AN10/RB1': 'A',
+                       'AN9/RB3' : 'A',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0011': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'A',
+                       'AN10/RB1': 'A',
+                       'AN9/RB3' : 'A',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0100': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'A',
+                       'AN9/RB3' : 'A',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0101': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'A',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0110': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0111': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1000': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1001': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1010': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1011': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1100': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'D',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1101': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'D',
+                       'AN2/RA2' : 'D',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1110': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'D',
+                       'AN2/RA2' : 'D',
+                       'AN1/RA1' : 'D',
+                       'AN0/RA0' : 'A',
+         },
+         '1111': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'D',
+                       'AN2/RA2' : 'D',
+                       'AN1/RA1' : 'D',
+                       'AN0/RA0' : 'D',
+         },
+ },
+ '39760D': {
+         # same config for '0001' and '0010', only keep one config
+         # else will produce error in ADC lib generation
+         '0000': {
+                       'AN12/RB0': 'A',
+                       'AN11/RB4': 'A',
+                       'AN10/RB1': 'A',
+                       'AN9/RB3' : 'A',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0011': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'A',
+                       'AN10/RB1': 'A',
+                       'AN9/RB3' : 'A',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0100': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'A',
+                       'AN9/RB3' : 'A',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0101': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'A',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0110': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'A',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '0111': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'A',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1000': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'A',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1001': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'A',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1010': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'A',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1011': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'A',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1100': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'D',
+                       'AN2/RA2' : 'A',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1101': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'D',
+                       'AN2/RA2' : 'D',
+                       'AN1/RA1' : 'A',
+                       'AN0/RA0' : 'A',
+         },
+         '1110': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'D',
+                       'AN2/RA2' : 'D',
+                       'AN1/RA1' : 'D',
+                       'AN0/RA0' : 'A',
+         },
+         '1111': {
+                       'AN12/RB0': 'D',
+                       'AN11/RB4': 'D',
+                       'AN10/RB1': 'D',
+                       'AN9/RB3' : 'D',
+                       'AN8/RB2' : 'D',
+                       'AN7/RE2' : 'D',
+                       'AN6/RE1' : 'D',
+                       'AN5/RE0' : 'D',
+                       'AN4/RA5' : 'D',
+                       'AN3/RA3' : 'D',
+                       'AN2/RA2' : 'D',
+                       'AN1/RA1' : 'D',
+                       'AN0/RA0' : 'D',
+         },
+ },
+}

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