• AVR Freaks

Hot!dsPIC33CH128MP508 ADC speed does not work as per expectation

Author
CY Liew
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2019/08/20 20:03:59
  • Location: 0
  • Status: offline
2019/08/27 03:44:37 (permalink)
0

dsPIC33CH128MP508 ADC speed does not work as per expectation

Good day,
I am trying to run the ADC in <dsPIC33CH Curiosity Development Board> using MCC in MPLAB X IDE v5.25 to test on the stated 3.5Msps conversion rate. Followed the GUI in MCC, I managed to set up the ADC and collect 1000 sample data and perform speed calculation using 1kHz reference signal. 
I am using master core ADC on AN15 with below configuration.
(refer to attachment)
 
In my main code, I perform trigger and then transfer the data to array. Upon completion on getting 1000 data, then only transfer to PC thru UART.
        if (sw_value==0){
            printf ("ADC_START\r\n");
            int k;
            for (k = 0; k < adc_count; k++){
                if (ADCON3Lbits.SWCTRG == 0){
                    ADCON3Lbits.SWCTRG = 1;
                    while (ADC1_IsSharedChannelAN15ConversionComplete() == 0){}
                    adc_data[k] = ADCBUF15;
                }
            }
            int l;
            for (l = 0; l < adc_count; l++) {
                printf("%d \r\n", adc_data[l]);
            }
            printf ("ADC_END\r\n");
        }

I managed to reconstruct the sine wave that I have converted. Everything looks normal, except that the sampling time will never as fast as expected. According to MCC GUI, the conversation time should be 3.8us but no matter what I do, I will get a sampling rate of near 40us between two data point. There is a significant increase from 3.8us to 40us. 
I tried many configuration and check the application note <12-Bit High-Speed Multiple SARs ADC> again and again, but found no clue what I have done wrong.
Can anyone please point me out when I did wrong and make the conversion so bad?
 
Regards,
Liew

Attached Image(s)

#1

6 Replies Related Threads

    Ovollyn
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2019/07/17 10:29:37
    • Location: 0
    • Status: offline
    Re: dsPIC33CH128MP508 ADC speed does not work as per expectation 2019/08/29 12:42:30 (permalink)
    0
    Hi CY Liew,

    Not sure if this might be the problem, but what is the speed of your FOSC ?
    #2
    du00000001
    Just Some Member
    • Total Posts : 3172
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: dsPIC33CH128MP508 ADC speed does not work as per expectation 2019/08/29 14:08:57 (permalink)
    0
    What's the clock frequency you declared in MCC?
     
    If it's some clock requiring the use of the PLL: do you switch to this clock? Or do you assume that by some miracle this clock will be provided?

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #3
    CY Liew
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/08/20 20:03:59
    • Location: 0
    • Status: offline
    Re: dsPIC33CH128MP508 ADC speed does not work as per expectation 2019/08/29 16:45:00 (permalink)
    0
    Good day,
    I submitted this post few days ago and while waiting for it to be approved to be posted, I had solved the problem yesterday.
    You are right that it was due to clock speed that limiting the ADC from doing faster. I did try select PLL clock in the ADC setting page in MCC but it won't work. Then after sometimes later, I discovered that I can increase Fosc with another PLL setting in system module (there are two PLL setting group in system module) and increase it from default 8MHz to 150MHz. This has significantly increase the speed and I am able to sample signal at 1.5us now. Even though it doesn't perform up to specification, nevertheless it is good enough for my application which I only converting signal up to 50kHz.
    I aware of clock setting but unfortunately Microchip provides very limited info on this dsp33 and the info are pieces scatter around datasheet, developer page and forum. There is also lack of application notes for this curiosity board which I believe this board is meant for someone new to it to try out.
    Anyway, the problem is solved as mentioned above. Thank you for your fast replies!

    Regards,
    Liew
    #4
    du00000001
    Just Some Member
    • Total Posts : 3172
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: dsPIC33CH128MP508 ADC speed does not work as per expectation 2019/08/29 18:01:44 (permalink)
    0
    I do not rate Microchip's documentation system that bad:
    • for the microcontrollers you've got the datasheet, the errata sheet and the collection of FRMs.
    • for the starter kits and the curiosity boards some demo software plus the user manual.
    The application notes are usually targeting a single derivative (family), but can be ported with more or less effort to derivatives that sport the peripherals required. But there won't be an AN available for each and every application and derivative: that's really more than can reasonably be requested...

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #5
    CY Liew
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/08/20 20:03:59
    • Location: 0
    • Status: offline
    Re: dsPIC33CH128MP508 ADC speed does not work as per expectation 2019/08/29 19:58:01 (permalink)
    0
    As I mentioned earlier, the information is scattered everywhere. Datasheet tells you the detail of individual register and a brief description on what the feature does. While FRM tells you how to make it works but will not tell you in detail how to optimize/tweak it. I did not solve my problem by just calling a genie from the lamp, I did read those materials plus others experiences and then figure out I can boost the Fosc in another way to get better conversion rate. 
    For the starter kit's material, the user manual basically explains the hardware features only. And the demo code software, it is a zip of the source code with a readme file that tells you what is inside each folder and how to use the pre-programmed board. There is not even info on how to set up the project in MPLAB, no need to mention the lack of info on what the codes are doing.
    When reading other threads in this forum, I also noticed many new users complained on same thing. May be the info is good enough for experience users but not works well for new users. 
    #6
    du00000001
    Just Some Member
    • Total Posts : 3172
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: dsPIC33CH128MP508 ADC speed does not work as per expectation 2019/08/30 00:37:20 (permalink)
    0
    I have to admit that the documentation materials are targeting the professionals. This has less to do with "experience" than with education. For me - depending on the exact peripheral - FRMs are optional.
    What I forgot to mention previously: documentation on the development system (IDE, compilers etc.) is avaioable as well. It is installed with the respective development tool installation and doesn'r require a separate download.
    Anyway...

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5