2016-01-29 07:16 AM
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.
2016-02-01 08:25 AM
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
2016-02-01 06:42 AM
Hello Ivan ,
Did you solve your issue ? you should receive EOC Interrupt (end Of Conversion)IRQ_HANDLER(SPC5_ADC1_EOC_HANDLER) {
Best regards
Erwan
2016-02-01 08:25 AM
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