Help using the ADC
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-01-29 7:16 AM
Posted on January 29, 2016 at 16:16
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
#discovery #adc #board
Solved! Go to Solution.
Labels:
- Labels:
-
ADC
This discussion is locked. Please start a new topic to ask your question.
1 ACCEPTED SOLUTION
Accepted Solutions
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-02-01 8:25 AM
Posted on February 01, 2016 at 17:25
Hello Erwan,
I discovered the issue and it was more simple that I belevied. It was necessary separate the configuration registry input to the start register input. To be clear, I changedADC0.MCR.R = OWREN_MASK | WLSIDE_MASK | MODE_MASK | START_MASK;
with
ADC0.MCR.R = OWREN_MASK | WLSIDE_MASK | MODE_MASK;
ADC0.MCR.R = ADC0.MCR.R | START_MASK;
As you can see, first I configure the MCR registry, than I give the start settin to 1 the NSTART bit field (using the mask).
Doing so, the channel configured are activated and I can read the input vlaue of the ADC.
Regards,
Ivan
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-02-01 6:42 AM
Posted on February 01, 2016 at 15:42
Hello Ivan ,
Did you solve your issue ? you should receive EOC Interrupt (end Of Conversion)IRQ_HANDLER(SPC5_ADC1_EOC_HANDLER) {
Best regards
Erwan
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-02-01 8:25 AM
Posted on February 01, 2016 at 17:25
Hello Erwan,
I discovered the issue and it was more simple that I belevied. It was necessary separate the configuration registry input to the start register input. To be clear, I changedADC0.MCR.R = OWREN_MASK | WLSIDE_MASK | MODE_MASK | START_MASK;
with
ADC0.MCR.R = OWREN_MASK | WLSIDE_MASK | MODE_MASK;
ADC0.MCR.R = ADC0.MCR.R | START_MASK;
As you can see, first I configure the MCR registry, than I give the start settin to 1 the NSTART bit field (using the mask).
Doing so, the channel configured are activated and I can read the input vlaue of the ADC.
Regards,
Ivan
