ADC inputs yet again

Post Reply
Bernard Leak
Posts: 18
Joined: Fri Aug 15, 2008 3:42 pm
Location: Armitage, Staffordshire, England

ADC inputs yet again

Post by Bernard Leak » Tue Apr 14, 2009 3:52 pm

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.

Bernard Leak
Posts: 18
Joined: Fri Aug 15, 2008 3:42 pm
Location: Armitage, Staffordshire, England

Re: ADC inputs yet again

Post by Bernard Leak » Thu Apr 16, 2009 11:38 am

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).
Attachments
dummy.c
(2.62 KiB) Downloaded 461 times
dummy.mdl
(63.02 KiB) Downloaded 485 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: ADC inputs yet again

Post by LubinKerhuel » Fri Apr 17, 2009 6:14 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests