Author: sebastien.lelong
Date: Sun Jul 5 10:34:31 2009
New Revision: 1094
Modified:
trunk/include/peripheral/adc/adc_channels.jal
trunk/tools/adc/adc_channels.jal.tmpl
Log:
fix filtering (copy PCFG bits combinations before modifying them. Thanks,
unittests ! ;)
Modified: trunk/include/peripheral/adc/adc_channels.jal
==============================================================================
--- trunk/include/peripheral/adc/adc_channels.jal (original)
+++ trunk/include/peripheral/adc/adc_channels.jal Sun Jul 5 10:34:31 2009
@@ -116,6 +116,7 @@
if target_chip == PIC_18F8585 | target_chip == PIC_18F8680 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)
@@ -148,56 +149,56 @@
pin_AN3_direction = input
elsif (ADC_NCHANNEL) == 6 then
pin_AN2_direction = input
- pin_AN5_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
+ pin_AN5_direction = input
pin_AN0_direction = input
pin_AN3_direction = input
elsif (ADC_NCHANNEL) == 7 then
pin_AN2_direction = input
- pin_AN5_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_AN5_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_AN5_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_AN5_direction = input
pin_AN4_direction = input
+ pin_AN9_direction = input
pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN9_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_AN5_direction = input
pin_AN4_direction = input
+ pin_AN9_direction = input
pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN9_direction = input
+ pin_AN5_direction = input
pin_AN7_direction = input
pin_AN0_direction = input
pin_AN3_direction = input
@@ -205,11 +206,11 @@
pin_AN6_direction = input
elsif (ADC_NCHANNEL) == 12 then
pin_AN2_direction = input
- pin_AN5_direction = input
pin_AN4_direction = input
+ pin_AN9_direction = input
pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN9_direction = input
+ pin_AN5_direction = input
pin_AN7_direction = input
pin_AN0_direction = input
pin_AN3_direction = input
@@ -218,11 +219,11 @@
pin_AN6_direction = input
elsif (ADC_NCHANNEL) == 13 then
pin_AN2_direction = input
- pin_AN5_direction = input
pin_AN4_direction = input
+ pin_AN9_direction = input
pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN9_direction = input
+ pin_AN5_direction = input
pin_AN12_direction = input
pin_AN7_direction = input
pin_AN0_direction = input
@@ -232,13 +233,13 @@
pin_AN6_direction = input
elsif (ADC_NCHANNEL) == 14 then
pin_AN2_direction = input
- pin_AN5_direction = input
- pin_AN13_direction = input
pin_AN4_direction = input
+ pin_AN9_direction = input
pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN9_direction = input
+ pin_AN5_direction = input
pin_AN12_direction = input
+ pin_AN13_direction = input
pin_AN7_direction = input
pin_AN0_direction = input
pin_AN3_direction = input
@@ -249,19 +250,19 @@
asm nop
elsif (ADC_NCHANNEL) == 16 then
pin_AN2_direction = input
- pin_AN5_direction = input
- pin_AN13_direction = input
- pin_AN14_direction = input
pin_AN4_direction = input
+ pin_AN15_direction = input
+ pin_AN9_direction = input
pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN9_direction = input
+ pin_AN5_direction = input
pin_AN12_direction = input
+ pin_AN13_direction = input
pin_AN7_direction = input
pin_AN0_direction = input
pin_AN3_direction = input
pin_AN10_direction = input
- pin_AN15_direction = input
+ pin_AN14_direction = input
pin_AN11_direction = input
pin_AN6_direction = input
end if
@@ -273,6 +274,7 @@
if target_chip == PIC_18F6680 | target_chip == PIC_18F6585 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)
@@ -305,56 +307,56 @@
pin_AN3_direction = input
elsif (ADC_NCHANNEL) == 6 then
pin_AN2_direction = input
- pin_AN5_direction = input
pin_AN4_direction = input
pin_AN1_direction = input
+ pin_AN5_direction = input
pin_AN0_direction = input
pin_AN3_direction = input
elsif (ADC_NCHANNEL) == 7 then
pin_AN2_direction = input
- pin_AN5_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_AN5_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_AN5_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_AN5_direction = input
pin_AN4_direction = input
+ pin_AN9_direction = input
pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN9_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_AN5_direction = input
pin_AN4_direction = input
+ pin_AN9_direction = input
pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN9_direction = input
+ pin_AN5_direction = input
pin_AN7_direction = input
pin_AN0_direction = input
pin_AN3_direction = input
@@ -362,11 +364,11 @@
pin_AN6_direction = input
elsif (ADC_NCHANNEL) == 12 then
pin_AN2_direction = input
- pin_AN5_direction = input
pin_AN4_direction = input
+ pin_AN9_direction = input
pin_AN8_direction = input
pin_AN1_direction = input
- pin_AN9_direction = input
+ pin_AN5_direction = input
pin_AN7_direction = input
pin_AN0_direction = input
pin_AN3_direction = input
@@ -384,6 +386,7 @@
if target_chip == PIC_16F870 then
+
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
@@ -422,10 +425,11 @@
if target_chip == PIC_16F871 then
+
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [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 [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
@@ -451,6 +455,24 @@
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
@@ -462,6 +484,7 @@
if target_chip == PIC_16F73 | target_chip == PIC_16F76 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)
@@ -497,10 +520,11 @@
if target_chip == PIC_16F74 | target_chip == PIC_16F77 then
+
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
- const byte ADC_PCFG_MAP [18] = {0b_110, 0b_0, 0b_0, 0b_0, 0b_0,
0b_0, 0b_0, 0b_0, 0b_0, 0b_100, 0b_101, 0b_0, 0b_0, 0b_0, 0b_0, 0b_000,
0b_001, 0b_0}
+ const byte ADC_PCFG_MAP [27] = {0b_110, 0b_0, 0b_0, 0b_0, 0b_0,
0b_0, 0b_0, 0b_0, 0b_0, 0b_100, 0b_101, 0b_0, 0b_0, 0b_0, 0b_0, 0b_010,
0b_011, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_0, 0b_000, 0b_001, 0b_0}
var bit*3 no_vref = 0
var bit*3 one_vref = 0
var bit*3 two_vref = 0
@@ -520,6 +544,19 @@
elsif (ADC_NCHANNEL) == 5 then
pin_AN4_direction = input
pin_AN2_direction = input
+ pin_AN0_direction = input
+ pin_AN1_direction = input
+ pin_AN3_direction = input
+ elsif (ADC_NCHANNEL) == 6 then
+ asm nop
+ elsif (ADC_NCHANNEL) == 7 then
+ asm nop
+ elsif (ADC_NCHANNEL) == 8 then
+ pin_AN7_direction = input
+ pin_AN5_direction = input
+ pin_AN6_direction = input
+ pin_AN4_direction = input
+ pin_AN2_direction = input
pin_AN3_direction = input
pin_AN0_direction = input
pin_AN1_direction = input
@@ -534,6 +571,7 @@
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)
@@ -645,6 +683,7 @@
if target_chip == PIC_16F747 | target_chip == PIC_16F777 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)
@@ -783,6 +822,7 @@
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)
@@ -881,6 +921,7 @@
if target_chip == PIC_16F72 then
+
-- This array stores PCFG config bits, 3 by 3, for each number of
-- ADC channels, from 1 to the max:
-- For each 3-tuple: (no vref, 1 vref, 2 vref)
@@ -918,6 +959,7 @@
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)
@@ -956,10 +998,11 @@
if target_chip == PIC_16F874A | target_chip == PIC_16F877A 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 [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
@@ -985,6 +1028,24 @@
pin_AN0_direction = input
pin_AN2_direction = input
pin_AN3_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
+ asm nop
+ elsif (ADC_NCHANNEL) == 8 then
+ pin_AN4_direction = input
+ pin_AN1_direction = input
+ pin_AN7_direction = input
+ pin_AN6_direction = input
+ pin_AN0_direction = input
+ pin_AN5_direction = input
+ pin_AN2_direction = input
+ pin_AN3_direction = input
end if
end if
@@ -996,6 +1057,7 @@
if target_chip == PIC_16F716 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)
@@ -1030,6 +1092,7 @@
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)
@@ -1068,10 +1131,11 @@
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 [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 [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
@@ -1097,6 +1161,24 @@
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
@@ -1108,6 +1190,7 @@
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)
@@ -1146,10 +1229,11 @@
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 [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 [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
@@ -1175,6 +1259,24 @@
pin_AN0_direction = input
pin_AN2_direction = input
pin_AN3_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
+ asm nop
+ elsif (ADC_NCHANNEL) == 8 then
+ pin_AN4_direction = input
+ pin_AN1_direction = input
+ pin_AN7_direction = input
+ pin_AN6_direction = input
+ pin_AN0_direction = input
+ pin_AN5_direction = input
+ pin_AN2_direction = input
+ pin_AN3_direction = input
end if
end if
@@ -1186,6 +1288,7 @@
if target_chip == PIC_16F872 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)
@@ -1224,6 +1327,7 @@
-- Datasheet: 39598E
if target_chip == PIC_16F818 | target_chip == PIC_16F819 then
+
-- This array stores PCFG config bits, 3 by 3, for each number of
Modified: trunk/tools/adc/adc_channels.jal.tmpl
==============================================================================
--- trunk/tools/adc/adc_channels.jal.tmpl (original)
+++ trunk/tools/adc/adc_channels.jal.tmpl Sun Jul 5 10:34:31 2009
@@ -29,6 +29,8 @@
#end def
+#import copy
+
#def deps
#end def
@@ -55,7 +57,7 @@
#end def
#def pcfg_conf(dsref,pics)
- #set confs = $adc_pcfg[$dsref]
+ #set confs = copy.deepcopy($adc_pcfg[$dsref])
## clean/remove some pins when not available in given PICs
## (given PICs all have the same pins, but the confs/combination
## may be a merge for different PICs. Ex: 16F77 has RE pins, not 16F76)
@@ -70,6 +72,7 @@
#end if
#end for
#end for
+
#set mapping = dict()
##-- These are some constants similar to what can be found in
MCC18 adc.h header file
#for bits,dpins in confs.items()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---