• AVR Freaks

Hot!How to achieve maximum frequency with the dspic33ch128MP508

Author
musculus
New Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/06/01 06:01:52
  • Location: 0
  • Status: offline
2019/08/08 01:07:08 (permalink)
0

How to achieve maximum frequency with the dspic33ch128MP508

Hi,
I am making a prototype of a device based on a dual-core dsPIC33CH128MP508. I got the chips as samples from Microchip. These are chips from one of the first series, I got them shortly after the start of production.
PCB is my design. The program is simple - flashing LEDs. I have a problem reaching the rated operating frequency. For the master core, I should reach 180MHz. Meanwhile, this core stably works to a frequency of about 140MHz. For the slave core it should be 200MHz, while I reach about 170MHz. When the processor is cold, it is possible to achieve a frequency of several MHz higher. When I set the frequency too high, the program starts working badly (behaves unpredictably and hangs). If I raise the frequency only for one core, the other one works correctly, only the one with the increased frequency fails.
I'm using MCC to configure the oscillator. I am based on an internal 8MHz oscillator.
I do not know if the error is in the MCC configuration (although it does not report any errors) or on my PCB (although I saw the supply voltage on the oscilloscope and it looks clean), or are the Microchip samples have any restrictions on the maximum operating frequency? Can you help me identify the problem?
#1

13 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3142
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/08 02:00:30 (permalink)
    0
    We had at least 1 thread about a similar issue. IIRC it was about not reaching the 100 MIPS withva CK derivative. Can't recall details.
     
    So, if you search the forums a bit ...

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    ric
    Super Member
    • Total Posts : 24156
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/08 02:06:53 (permalink)

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    du00000001
    Just Some Member
    • Total Posts : 3142
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/08 02:22:58 (permalink)
    0
    @ ric
    Thanks for digging - seems this is the one I remember.
    Funny - it ran from October last year to May this year.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #4
    musculus
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2017/06/01 06:01:52
    • Location: 0
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/09 03:39:17 (permalink)
    0
    Thanks for the answer. Unfortunately that thread concerns a different chip. The solution given there (programming two undocumented bits) is not suitable for my case, because in the case of a processor from the CH family, the state of these bits according to the documentation is to be one, not zero (i.e. as in the unprogrammed state). I can test manually force setting these bits to zero, but I don't know how to do it (I wrote programs mainly in assembler, I am still learning C language and I don't know how to force it).
    However, I also tested my program on the dsPIC33CH Curiosity board and it behaves exactly the same as on my PCB design. So I suppose it will not be a matter of the PCB design.
    I noticed one more thing: When I set the lower clock on the master core then I can go higher with the clock for the slave core. With a master clock of 140MHz, the slave clock can be 171MHz. With a 50MHz master clock, the slave clock can be 180MHz. I wonder if this is a matter of some problems with the chip itself (both chips tested by me - the one soldered by me and the one installed on the Curiosity board - come from the same series: 1814 7QC).
    post edited by musculus - 2019/08/09 03:48:00
    #5
    du00000001
    Just Some Member
    • Total Posts : 3142
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/09 04:01:08 (permalink)
    0
    Considering the interdependency, this might be a power supply issue. Better to check the supply voltage.
    In addition, a look into the errata sheet might no hurt: there is an issue with the FRC/PLL.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #6
    Ovollyn
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2019/07/17 10:29:37
    • Location: 0
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/09 06:56:07 (permalink)
    0
    Dear musculus,

    How do you measure your core frequency ? I think it is not really clear what microchip is trying to explain us when they say the core can run up to "200MHz". Actually, this is the clock frequency, yes, but it is divided by two. So, the clock output you'll get with a 200MHz clock will be 100MHz, not 200Mhz. Same as they say, for the main core, the maximum MIPS (Mega instruction per second) is 100 = 200/2. So, maybe your clock is now running at 280MHz, but what you are measuring is 140MHz, because of this factor of 2, which would mean you already went beyond the limit (badass) ?

    Not 100% sure of this, but maybe this might be the answer ?

    Regards,

    M.
     
    #7
    NorthGuy
    Super Member
    • Total Posts : 5733
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/09 07:08:29 (permalink)
    0
    Check if you have bypass capacitors and that they're soldered well. They are necessary at higher frequencies.
     
    <edit>Also check if the power is Ok. Higher frequencies will require more power.
    post edited by NorthGuy - 2019/08/09 07:10:26
    #8
    davekw7x
    Entropy++
    • Total Posts : 1827
    • Reward points : 0
    • Joined: 2012/01/16 12:01:07
    • Location: Second star on the right, straight on till morning
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/10 16:32:19 (permalink)
    5 (1)
    musculus
    ...I also tested my program on the dsPIC33CH Curiosity board and it behaves exactly the same as on my PCB design...

    Sigh...
    The other thread (about the CK device) went on and on (and on) after I reported success running at full speed (but I didn't give details)
    It turned out that there were "issues" that I would never have run into because of the way I let MPLABX generate the configuration pragmas.  (Or, using MCC for those projects.)

    I have never had much satisfaction (or success) debugging other folks' hardware (layout, component selection, power, etc.) by remote control, so I (usually) don't even try.

    Anyhow, since in the present thread it was reported that there are "issues" with the CH chip at full speed even with a Curiosity board, I decided to post a complete project that works for me at full speed.

    So...

    I took the Microchip test program for the dsPIC33CH128MP508 with a few mods to illustrate running the Master Core at 90 MIPS and Slave Core at 100 MIPS on my Curiosity Board. (See Footnote.)  Actually, I did this some time ago and passed along project files and notes to a few secret friends.  It's, perhaps, a starting point for a "real" project.

    Comments in main.c of each project give a description of the functionality.

    Bottom line: Worked as I expected, based on the Data Sheet and the MCC setup for Master and Slave.

    I used the external 8 MHZ clock on the Curiosity board.

    UART ports are set to 115200 Baud by MCC.

    LEDS are toggled with functionality defined by Master-Slave communications protocol, and cadence determined by __delay_ms() based on FCY calculated from MCC-generated _XTAL_FREQ.

    Output, using terminal emulator minicom, from PC USB port connected to Curiosity "USB-Uart" connector, J16:
    Master compiled on Aug 10 2019 at 14:28:30 by XC16 version 1036
    _XTAL_FREQ = 180000000, FCY = 90000000

    Output from USB-to-Logic converter connected to RD0 and RD1 at the mikroBUS A port (J3):
    Slave compiled on Aug 10 2019 at 14:28:18 by XC16 version 1036
    _XTAL_FREQ = 200000000, FCY = 100000000
     
    (MPLABX version 5.15, MCC plug-in 3.75, XC16 version 1.36B)

    Debugging with the Curiosity's PKOB would be a real pain since it won't let me set breakpoints while running.  I mean, I was able to set a breakpoint in the Master main() function and single-step through some sequences, but since I would have to re-compile each time I want to change the breakpoint location, it's easier (especially for an old-school curmudgeon like me) to just sprinkle printf() around the landscape to verify proper operation during step-at-a-time development.  (See Footnote.)  My point is that it works for me.
     
    I don't usually post full code for projects, but after enduring the other agonizing thread, I'll break with personal tradition.
     
    Bottom line suggestion:
    The forum won't let me post .zip files, so I tacked on .txt in order to attach the packaged files.  Rename them to be .zip (without the .txt) Put .zip files in some convenient MPLABX project directory (nnote: be sure to put them in the same directory) and unzip them.  You get two projects, named Master and Slave.  If your I/O connections are different, make changes in the source files (or, perhaps it would be better to let MCC do it for you).  If the Microchip tutorial is not completely adequate for your purposes, follow instructions in one of the many tutorials that are floating around.

    Regards,

    Dave

    Footnote:
    This demo project is for a PIM, but I/O is compatible with the Curiosity board:
    https://microchipdevelope...-for-dual-core-devices

    Step-at-a-time development:
    First I read through the entire tutorial, and  I got things running exactly as described.  (Huzzah!)  I used MPLABX "package" function to make sure I had a fall-back position to something that works.  I package the projects whenever I make significant changes.  (The history function of the MPLABX editor lets you back out of text changes in source files, but the biggest headache for many folks is undoing changes in the MCC setup.)

    Then, using MCC, I made clock changes in both projects to get their cores running at max speed from the external 8 MHz clock input, and I added UARTs.  It's not really all that tough if you have read through the tutorial.  I don't recommend a "fiddle-fart-around-until-you-get-lucky approach.  Ars longa, vita brevis!

    Finally I changed the logic in the main() functions as described in the comments in the main.c files.
    post edited by davekw7x - 2019/08/10 16:51:49

    Sometimes I just can't help myself...
    #9
    musculus
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2017/06/01 06:01:52
    • Location: 0
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/12 03:42:45 (permalink)
    0
    Hi,
    Thanks for the answers.
    @Dave - I analyzed your code and it looks like you set Fosc/2 to 90MHz for the master core and 100MHz for the slave core, while I tried to set 180MHz and 200MHz, respectively.
    @Ovollyn - yes, it was unclear to me. Because the MCC displays a warning at 180MHz for the master and 200MHz for the slave, I thought that the operating frequency that Microchip gives in the datasheet is not Fosc, but Fcy (=Fosc/2) and that 90 MIPS is achieved not at Fosc=180MHz, but Fcy=180MHz. In this situation, it seems that I have significantly overclocked the processor and it is still working.
    I wonder, however, why MCC gives an appropriate warning only when the clock frequency is more than double the catalog value?
    #10
    davekw7x
    Entropy++
    • Total Posts : 1827
    • Reward points : 0
    • Joined: 2012/01/16 12:01:07
    • Location: Second star on the right, straight on till morning
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/12 10:39:37 (permalink)
    0
    musculus
    ...MCC displays a warning at 180MHz for the master and 200MHz for the slave, I thought that the operating frequency that...



    MIPS means "Millions of Instructions Per Second."  I do not see any ambiguity in the Data Sheet.
     
    Warnings are (sometimes) useful, but if you expect that MCC (or the compiler or any-blooming-other-thing) can catch all of your errors, you will find that life will be filled with endless disappointment and boundless frustration.
     
     
    Bottom line: Data Sheet first.  When things don't work as expected, it's back to the Data Sheet!
     
    Regards,
     
    Dave
    post edited by davekw7x - 2019/08/12 10:57:47

    Attached Image(s)


    Sometimes I just can't help myself...
    #11
    du00000001
    Just Some Member
    • Total Posts : 3142
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/12 12:10:42 (permalink)
    0
    MCC might displays when you violate the max. frequency of the respective PLL. But obviously not when you "mis-set" the post-divider. While MCC is not that bad for starters, it doesn't completely eliminate the need to consult the datasheet.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #12
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3293
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/12 12:42:53 (permalink)
    0
    These are the settings that I use:
    #define M                 80
    #define N1                 1
    #define N2                 4
    #define N3                 1
    #define FPLLI       20000000
    #define FVCO        (FPLLI * (M / N1))                    // 1,600,000,000
    #define FPLLO       (FPLLI  * (M / (N1 * N2 * N3)))       //   400,000,000
    #define FOSC        (FPLLO >> 1)                          //   200,000,000
    #define fcy         (FOSC  >> 1)                          //   100,000,000
    #define MIPS        fcy                                   //   100,000,000


    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #13
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3293
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: How to achieve maximum frequency with the dspic33ch128MP508 2019/08/12 12:52:24 (permalink)
    0
    Initializer code with clock out to a scope.
    int __attribute__((section("Gort1951"))) init_mastercpu(){
        //reference clock on pin 7, out @ fosc / 100
        _ppsenable();
        RPOR15bits.RP62R=_RPOUT_S1REFO;
        _ppsdisable();
           //scope tests x1, x10
        //200,000,000
        //20,000,000
        //REFOCONH=1000/2;
        REFOCONH=100/2;
        REFOCONH=0;//base clk
        //200khz * 1000 =
        //FOSC = 200,000,000
        REFOCONLbits.ROEN=1;
        REFOCONLbits.ROOUT=1;
        REFOCONLbits.ROSEL=0b0010; //primay osc
        //2,011,780 Hz
        //201,178,000
        //200,000,000
        while(REFOCONLbits.ROSWEN);
        CLKDIVbits.PLLPRE=N1;
        CLKDIVbits.FRCDIV=0;    //div by 1 bug fix
        PLLFBDbits.PLLFBDIV=M;
        //OSCTUN=0;
        PLLDIVbits.VCODIV=0b11;    // FVCO / 1
        PLLDIVbits.POST1DIV=N2;
        PLLDIVbits.POST2DIV=N3;
        _setosccon(0b011);  //Primary Oscillator HS with PLL HSPLL
        //0.008 % out from 20MHz
        return 0;
    }

    post edited by Gort2015 - 2019/08/12 12:53:45

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5