I admire your perseverance.
Now, let me just say that I do understand what the datasheet / user reference manual says. Plus, I'm only a newbie on the forum and not much else. However, I have found several mistakes in both manuals regarding the ADC. Using the MCC was no help, because it gave the the reported clock warning. And computing T = 1 / f = 1 / 70MHz yielded approximately the 14.3ns specification which is the highest setting for which the MCC does not complain about. All of this made me to believe that they have included a clock (and I mean frequency) multiplier in the ADC.
As of now, I have done the tests I have suggested earlier using the following setup:
- MCU: dspic33ck256MP508
- Compiler / IDE: XC16 v1.36B / MPLAB X v5.20
- Clock: FRC+PLL @100MHz with prescaler = 1, feedback = 150, postscaler1 = 3, postscaler2 = 2
- ADC: Clock Divisior (CLDIV) = 1, ADCS = 0 (which halves the clock) and sampling time of 6 TAD for the shared and core0
- Toggling a LED marked the begging and end of the sampling+conversion, where the pulse width was measured with TBS1152 oscilloscope
At this clock I assume its safe to test the ADC, since the datasheet reads:
"Note 1: The ADC input clock frequency, selected by the CLKSEL[1:0] bits, must not exceed 560 MHz.
2: The ADC clock frequency, after the divider selected by the CLKDIV[5:0] bits, must not exceed 280 MHz"
Also I did two builds with the same clock and ADC settings:
- first build: using a firmware I had at hand
- second build: barebone project with Clock / ADC / UART
Results:
- the interrupt latency is around 520ns +/- a few nano seconds for both builds (measured using two gpios).
- on the first build the ADC gave me weird results for measured values. All conversions took way longer than those with the 70MHz clock. The average per sampling + conversion was at 4.5us . These, of course, are bogus and don't correspond to the expected 980ns by a huge margin. Other divisors yielded even weirder results, some of which took way longer and some of which took way shorter periods.
- on the second build, the ADC gave me the correct results averaging 987ns per sampling + conversion. I also obtained good results for CLDIV = 2, ADCS = 0 or CLDIV = 1, ADCS = 2, both settings averaging around 1956ns per sampling + conversion. In this instance all the ADC measured values were as expected.
@JPortici, @NorthGuy Hence, congrats you were right! Its a divisor as one usually expects.
@uer166 However, I still don't recommend using the highest possible clock, especially with the ADC since its always impacted by temperature variations and clock drifts.