• AVR Freaks

Hot!PIC32MX575F512L

Author
patpapin
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2010/04/06 02:45:11
  • Location: 0
  • Status: offline
2019/03/20 08:08:31 (permalink)
0

PIC32MX575F512L

HI,
 
I use a PIC32MS575F512L, the internal clock for peripheral PBCLK = 80MHz
I use the output compare module and the timer 2 for generate a clock on OC5 at 25MHz.
When i configure the timer 2 and the out compare module for this freqency my program doesn't work.
How generate a clock  at 25MHz?
 
Best regards,
 
Patrick
 
#1

6 Replies Related Threads

    JPortici
    Super Member
    • Total Posts : 726
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: PIC32MX575F512L 2019/03/20 08:23:09 (permalink)
    0
    Who knows why it doesn't work!
    Who knows what "doesn't work" mean!
     
    We haven't seen the code.
     
    Please use the code tags to post code.
    Please in the future put a more meaningful title to your thread.
     
    Anyway, if i read the datasheet correctly this MCU doesn't have a fractional clock generator, since 25 is not an integer divisor of 80 i don't see a way to generate a 25MHz clock from 80MHz on this MCU
    #2
    Larry.Standage
    Super Member
    • Total Posts : 909
    • Reward points : 0
    • Joined: 2011/12/30 09:50:47
    • Location: 0
    • Status: offline
    Re: PIC32MX575F512L 2019/03/20 08:57:08 (permalink)
    0
    I don't think you're going to be able to do it with the 80MHz parts. The period of the OC is going to be some multiple of the 80MHz input, but you can't get to 25MHz from 80MHz evenly, let alone getting the setting to toggle the line in between. Given that the PWM period is defined by PRy+1, I think the best you can hope for would be 20MHz.
     
    You might be able to get it to work with a part that runs at 100MHz, or one of the MZ parts with a 100MHz peripheral clock. But I haven't tested it.
     
     
    #3
    patpapin
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2010/04/06 02:45:11
    • Location: 0
    • Status: offline
    Re: PIC32MX575F512L 2019/03/21 05:32:52 (permalink)
    0
    Hi Larry
    Thank you for your response.
    I change my µP (PIC32MX575F512L) by PIC32MX470F512L
    it are compatible pin à pin and the internal clock for peripheral PBCLKmax = 120MHz
    what is the best module (output compare,or other) for generate a clock at 25MHz (or 28.8MHz)?
    Best regards,
     
    Patrick
    #4
    Larry.Standage
    Super Member
    • Total Posts : 909
    • Reward points : 0
    • Joined: 2011/12/30 09:50:47
    • Location: 0
    • Status: offline
    Re: PIC32MX575F512L 2019/03/22 12:35:27 (permalink)
    4 (1)
    I set up a PIC32MX470 to run at 100 MHz, then set Timer2 and OC2 as follows:
    // Pinouts. RPB14 for OC2
    RPB14R = 0b1011;

    // Timer2 will drive OC.
    PR2 = 3; // PB Clock is divided by PR2+1

    // Output Compare 2 for PWM mode, 50% duty cycle
    OC2RS = 2; // 1/2 of PR2+1
    OC2R = 2;
    OC2CON = 0x6;

    T2CONSET = 0x8000;
    OC2CONSET = 0x8000;

    Using that setup, I was able to get a 25 MHz signal, though it doesn't seem to be what I would call rock-solid. There seems to be some jitter that I can't get around. The frequency is 25 MHz, but not always with a 50% duty cycle. It seems to occasionally be 60%.
     
    Since you've switched to the MX470, though, you can use the REFCLK module to generate the 25 MHz. It's also a much simpler setup, and is rock solid 50% duty cycle.
    // REFCLKO setup. Pin RPE3
    RPE3R = 0b0011; // REFCLKO -> RE3

    REFOCONSET = (0b10 << 16) | // RODIV setting, divide by 4
    (1 << 12) | // Output Enable
    (1 << 15) | // On
    (1 << 9); // DIVSWEN, so the switch takes place

     
    If you want 28.8 MHz, you can include the REFOTRIM bits to fractionally adjust the divider, but you will have more jitter, especially the closer you get to the midpoint of the register. 120MHz might make it a little better.
    #5
    patpapin
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2010/04/06 02:45:11
    • Location: 0
    • Status: offline
    Re: PIC32MX575F512L 2019/03/28 08:37:36 (permalink)
    0
    Hi Larry,
    Thank you for your response.

    The internal frequency of the PIC is 115.2MHz
     I generate a signal with a clock @28.8MHz (with the output compare module): signal OK.
    The value of TMR2 = 3, OC5RS and OC5R =2.


    I have an other timer (Timer1) who pilot a led every 1seconds (blinking)

    When only the timer 1 is ON, the LED blink normally.


    When i turn ON the timer2  and add the OC5 interrupt for my clock, only the OC5 interrupt are OK.
    The prioritys of the 2 interrupts are equal

    I think the PIC turn only for OC5 module (the breakpoint in timer1 don't work?): problem of internal frequency and the pic don't able to do other thing with an interrupt so quick?

    What do you think about my problem?

    Best regards,
     
    Patrick
    #6
    davekw7x
    Entropy++
    • Total Posts : 1815
    • Reward points : 0
    • Joined: 2012/01/16 12:01:07
    • Location: Second star on the right, straight on till morning
    • Status: offline
    Re: PIC32MX575F512L 2019/03/28 09:33:00 (permalink)
    0
    patpapin
    ...
    and the pic don't able to do other thing with an interrupt so quick?
    ...

    Haven't you answered your own question?
     
    Originally...
    You wanted to generate an output clock whose frequency is the system frequency divided by 4.  Problem solved ---thanks to LSMFT (Larry Standage's Mighty Fine Technique)--- right?
     
    Now...
    You are trying to respond to an interrupt every four instruction cycles, right?

    Well...
    If, somehow, the Interrupt Service Routine could be made to do nothing other than reset the interrupt flag and return, it would take more than four instruction cycles to respond to an interrupt.  That means that upon return from the ISR it would be interrupted again immediately.  What useful task could possibly be implemented using this interrupt?  I mean, really...

    Bottom line...
    Think (yes, really: Think) about what the heck you are trying to do!  Time to revisit your requirements analysis.


    Regards,

    Dave
     
    post edited by davekw7x - 2019/03/28 09:55:13

    Sometimes I just can't help myself...
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5