Hi Rob,
The logic with ADC libs (2nd case, using ANS bits) is:
- ADC libs create aliases: ADC_JANSEL_ANSx => ADC_JANSEL_ANSy. x and y can
be the same. This is actually what's expected for most PIC in this 2nd case,
except those I mentioned ealier.
- in set_analog/digital_pin(num), which takes a number as input, the logic
is:
if num == x then
-- act on ADC_JANSEL_ANSx
-- setup pin_ANx_direction
there are plenty of these "if", for each ANSx. So the idea is users just
have to tell which ADC channel (where x means pin ANx from datasheet) they
want to activate/deactivate. If user says "set_analog_pin(5), then it should
act on pin AN5 (not RA5 for instance). The question now is: what if there's
no AN5 pin ? I think what you've done must actually be ok. Normalization is
now in device files for these PICs, so my normalization step in ADC libs is
now wrong, you were right, I read all of this too fast. I thought contigous
JANSEL_ANSx bits was important, but maybe not, I'll check this some more,
I'm currently quite lost with all these aliases and normalization :)
Cheers,
Seb
2010/3/25 Rob Hamerling <[email protected]>
>
>
> On 03/25/10 11:13 am, Sebastien Lelong wrote:
>
> I've missed something... In 16f722.jal, JANSEL_ANSx bits aren't
>> contigous anymore !
>>
>
> True, like there are gaps and irregular sequences in the pin/bit nummering
> of AN-pins in their respective registers. The 16F722 for example has pin_AN0
> to pin_AN3 on RA0 to RA3, but pin_AN4 is on RA5.
> This PIC does not have pin_AN5 to pin_AN7 and pin_AN8 to pin_AN13 are
> spread over RB0 to RB5 (typically Microchip style I would say!).
> There are similar 'irregularities' with many other PICs.
>
>
> The idea behind JANSEL_ANSx is to normalize these numbers and hide
>> complexity for ADC libs (in general, not for these PICs). Specifically,
>> there exception handling for these PICs: 16F722, 16F723, 16F724, 16F726,
>> 16F727 + LF versions. So I'll update the extra normalization step, but
>> can you confirm there aren't such change in other PICs ? (for which ANSx
>> bits aren't contigous anymore)
>>
>
> There is obviously a misunderstanding! The idea of JANSEL was (in my view)
> to obtain a one-to-one relationship between JANSEL_ANSx and pin_ANx (with
> the same value of 'x'). So for example when using ADC channel 4: pin_AN4 is
> the input pin and control its analog setting is with JANSEL_ANS4. This
> sounds very obvious to me and is also similar to the PICs which use
> ANCON1_PCFGx bits for this purpose.
>
> I could make a list of all PICs with irregularities in their AN-pin
> numbering. But I'm pretty sure it will contain almost all PICs with
> JANSEL_ANSx (except for the very small ones with 2 or 3 ADC channels which
> are difficult to randomize!). You might as well use the FindJANSEL wiki,
> which was really meant to show how AN-pins are organised.
>
> I'm sorry when I've caused trouble, of course unintentionally.
>
>
> Regards, Rob.
>
> --
> Rob Hamerling, Vianen, NL (http://www.robh.nl/)
>
> --
> 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]<jallib%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/jallib?hl=en.
>
>
--
Sébastien Lelong
http://www.sirloon.net
http://sirbot.org
--
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.