AnsweredAssumed Answered

Help using the ADC

Question asked by colla.ivan on Jan 29, 2016
Latest reply on Feb 1, 2016 by colla.ivan
Good morning,

I am trying to activate and use tha A/D converter.

After activating the peripheral, I proceed to set the register in this way:

ADC0.NCMR0.R = 0b00000000000000001111111111111111;                   /* Enable all conversion channel for test.*/
 
ULONG OWREN_MASK = 1 << 31;              /* Enable conversion data to be overwritten. */
ULONG WLSIDE_MASK = 1 << 30;             /* Conversion data written right-aligned. */
ULONG MODE_MASK = 1 << 29;               /* Continuous scan conversion. */
 
ULONG START_MASK = 1 << 24;             /* Start conversion on enabled channels. */
 
ADC0.MCR.R = OWREN_MASK | WLSIDE_MASK | MODE_MASK | START_MASK;

when I execute the code on the discovery board, I wait for a valid data on one of the channels.

if (ADC0.CDR0.B.VALID == 1)

Following discovery-board manual, the AD0 port (B7), is accessible via pin A26 of the connector.
I connect to that pin a 5 V voltage, expecting to read something.

The problem is that I don't read anything. Monitoring the all the CDRn registers, I see that neither of them has a new convertion valued stored: tha data field is 0 and the VALID field is 0.

What am I missing?

Regards,
     Ivan

Outcomes