Page 1 of 1

ADC inputs yet again

Posted: Tue Apr 14, 2009 3:52 pm
by Bernard Leak
It has been some months since I last picked up a new copy of the block-set, and the latest
version seems to have broken something which once worked.

The default behaviour seems to be to leave all analogue input pins configured for
analogue input. Explicitly putting a digital I/O block in a model would set bits in the
AD[12]PCFG[HL] registers to disable them as analogue inputs. In the past, I have
used digital input blocks driving terminator blocks. to ensure that I could use the
associated pin as a digital I/O pin (in code not visible in the Simulink model diagram).
This no longer works.

The analogue pins I am using are all in AN16-31 (so they are configured
in AD1PCFGH). The list is [ 16 17 18 19 20 22 23 24 25 26 ].
I am using AN27-AN31 as digital inputs. Whereas AD1PCFGH used
to be set (correctly) to 0xF800, it is now left as 0 (the default state
at start-up).

There has been some change in this area: in fact, I used to see compiler
warnings about 16-bit shifts on 16-bit quantities.

Re: ADC inputs yet again

Posted: Thu Apr 16, 2009 11:38 am
by Bernard Leak
Here's a tiny illustrative model. This one shows the problem even though
there is no ADC input at all!

On this CPU (dsPIC33FJ256GP710) the digital I/O pins given are
also analogue inputs (numbered as labelled). At power-on, all the
analogue input pins are configured as ADC inputs by default,
represented by 0 bits in the ADxPCFGL and AD1PCFGH registers.
The generated dummy.c file has all the appropriate details.
TRISE is (correctly) left with all bits set, so all the pins are inputs.
However, AD1PCFGH is left with all bits clear, so AN16-AN31
are configured as analogue inputs only; port read input is disabled,
so the actual state of the pin isn't read.

AD1PCFGL and AD2PCFGL are explicitly (and redundantly)
set to their default value of 0. This guarantees that the
same problem will also affect AN0-AN15 (it so happens that
I wasn't using any of these as inputs).

Re: ADC inputs yet again

Posted: Fri Apr 17, 2009 6:14 pm
by LubinKerhuel
Thanks again for this clear bug description with simulin example.It really helped to track it !

the bug is corrected and the corrected blockset version will be available in the next blockset version (following version 0.99c)

Lubin