Hi Rob,
Thinking again about this naming convention... Here the kind of code that I
could write for VCFG bits:
(say ADC_NVREF is the number of vref, can have value 0, 1 or 2)
- When separated in VCFG0 and VCFG1:
if ADC_NVREF == 1 then
VCFG0 = true
end if
if ADC_NVREF == 2
VCFG1 = true
end if
- When defined as bit*2:
VCFG = ADC_NVREF
The 2nd one, which corresponds to the opposite of what I've suggested, is
far simpler... but does not correspond to the datasheet notation !
So I don't know which is best. Maybe both ? :) What's your opinion on this ?
Cheers,
Seb
PS: just another question/remark. I know bit names are prefixed with
register name, to avoid naming collision. That's why we have ADCON0_VCFG and
ADCON1_VCFG. The code to handle this is more complex as a result:
Wanna set VCFG to 2 ?
if defined(ADCON0_VCFG) == true then
ADCON0_VCFG = 2
elsif defined(ADCON1_VCFG) == true then
ADCON0_VCFG
end if
instead of a common prefiex:
XXXXX_VCFG = 2
I know we don't have choice, this is just a remark. And fortunately, most of
my code is generated :)
Seb
> Hi Seb,
>
> Sebastien Lelong wrote:
>
> > I also had a look at VCFG bits. These bits are used to configured
> > Vref+/Vref-, or just Vref when only one available. These can only be
> found
> > when Vref config is not handled in PCFG bits. That is, when ADC pins are
> > independent from each other (you can precisely define which pin will be
> > analog).
> >
> > Currently, VCFG bits can be found as:
> >
> > ADCON0_VCFG
> > ADCON1_VCFG
> > ADCON1_VCFG0
> > ADCON1_VCFG1
> >
> >
> > The "problem" is sometime VCFG corresponds to only one bit (there's only
> one
> > VRef), and sometime these are defined as "bit*2". I think it would be
> better
> > to have VCFG0 and VCFG1 instead of a "bit*2 VCFG". See for instance:
> > - datasheet 41302B : one VCFG bit, one VRef
> > - datasheet 41303D : bit*2 VCFG bits, two VRef
> >
> > In 41303D, VCFG bits are referred as VCFG0 and VCFG1 bits.
>
> I shouldn't be a problem to declare VCFG as VCFG0 and VCFG1 if it is a
> 2-bits field. From your text above it seems only to appear in ADCON1,
> but I can check that myself.
>
> ---
>
> About the ANS bits: would it be useful to declare aliases for these
> bits? For example:
> var volatile bit ADC_ANS0 is ANSEL : 0
> and of course ANSEL:0 could be ADCON:0 or whatever is the real ANS0 bit?
> In that way the ADC library can always use the same name, without a need
> to know which is the real bit.
>
> Regards, Rob.
>
>
>
>
> >
>
--
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
-~----------~----~----~----~------~----~------~--~---