Author: robhamerling
Date: Sat Jul 4 11:53:37 2009
New Revision: 1080
Modified:
trunk/doc/html/devicefiles.html
Log:
New sections with description of pin-aliases and ADC channel selection
(ANSEL normalisation)
Modified: trunk/doc/html/devicefiles.html
==============================================================================
--- trunk/doc/html/devicefiles.html (original)
+++ trunk/doc/html/devicefiles.html Sat Jul 4 11:53:37 2009
@@ -261,8 +261,7 @@
<li>to ease the migration of programs to other types of PICs.
</ol>
-
-<h3>PORTx and TRISx</h3>
+<h3>PORTx and pins, TRISx and pin directions</h3>
<p>For all ports and port pins a device independent alias is declared and a
similar direction declaration, as the following examples show:
<pre>
@@ -327,6 +326,69 @@
<p>Several function libraries in the Jallib collection use this facility.
<P>Note: Nibbles are always declared even if the register doesn't have the
nibble fully populated (or not populated at all!) with pins.
+
+<h3>Alias names for pins</h3>
+<p>When a pin is multiplexed (has a different function depending on
+control registers or configuration bit settings), aliases are declared
+to make the pin accessible by a more functional name.
+For example: of the 16F88 pin_B6 is usable as analog input for the ADC
+module as channel 5 and therefore pin_B6 has been given an alias name
+pin_AN5.
+You can find the 'AN5' indication in the datasheet.
+<br)Of course also for the pin_B6_direction an alias is declared and
+called similarly pin_AN5_direction!
+<br>Libraries (for this example the ADC library) will use the alias
+names in stead of the physical pin names.
+Another PIC may have pin_AN5 associated with a different physical pin,
+but by using the alias names the ADC library becomes indenpent of the
+physical pin configuration
+and and makes it to a large extent device independent.
+
+
+<h3>Names of ANSEL bits</h3>
+<p>For the selection of the ADC channel the ADC library has to set the
+appropriate bit(s) of the ANSEL register(s), depending on the type of
+PIC.
+The baseline and midrange PICs have a couple of different ANSEL registers
+configurations.
+This would make it complicated to build a device independent ADC library.
+This is (partly) solved by declaring aliases for the channel selection
+bits in ANSEL registers.
+<br>The ANSx and ANSELx bits have a given prefix 'JANSEL' (a pseudo
+register name being a contraction of JALLIB-ANSEL).
+The name of the channel selection bit has the form AN<number>
+in which <number> counts from 0 to the maximum number,
+corresponding to the channel number in the datasheets.
+<br>As example below the declaration of ANS bit of the 16F886.
+This PIC has as ADC channels 0..4 and 8..13.
+<pre>
+var volatile byte ANSEL at { 0x188 }
+var volatile bit JANSEL_ANS4 at ANSEL : 4
+var volatile bit JANSEL_ANS3 at ANSEL : 3
+var volatile bit JANSEL_ANS2 at ANSEL : 2
+var volatile bit JANSEL_ANS1 at ANSEL : 1
+var volatile bit JANSEL_ANS0 at ANSEL : 0
+-- ------------------------------------------------
+var volatile byte ANSELH at { 0x189 }
+var volatile bit JANSEL_ANS13 at ANSELH : 5
+var volatile bit JANSEL_ANS12 at ANSELH : 4
+var volatile bit JANSEL_ANS11 at ANSELH : 3
+var volatile bit JANSEL_ANS10 at ANSELH : 2
+var volatile bit JANSEL_ANS9 at ANSELH : 1
+var volatile bit JANSEL_ANS8 at ANSELH : 0
+</pre>
+Another example for the 10F222:
+<pre>
+var volatile byte ADCON0 at { 0x7 }
+var volatile bit JANSEL_ANS1 at ADCON0 : 7
+var volatile bit JANSEL_ANS0 at ADCON0 : 6
+</pre>
+As you can see here the channel selection bits are in register ADCON0
+(the 10Fs have no ANSEL register), but the ADC library doesn't have
+to know!
+<br><i>Note: in reality the channel selection of the 10F220/222 is
+somewhat more complicated!</i>.
+
<h3>Names of MSSP modules</h3>
<p>Names of registers of MSSP modules have been normalized as follows:
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---