• AVR Freaks

Hot!Pic32MX Using FRC and LPRC together.

Author
SergioR
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2019/01/01 04:00:30
  • Location: Italy
  • Status: offline
2020/02/24 11:39:03 (permalink)
0

Pic32MX Using FRC and LPRC together.

Good morning.
Sorry in advance for the banality of my questions, but I'm quite new on PIC32.

I did a program for PIC32MZ
My application is really easy: the micro works for 150uSec then it does nothing for 5/6mSec.
For that reason I put it on sleep mode, in order to save power.

I'm using 2 external clock oscillators: a 24MHz as primary clock and a 32.768kHz
The secondary clock is used by Timer1 to wake up the controller.

Until here all is good

I'd like now to use now a PIC32MX and replace the external oscillators with internal clocks.
I was thinking to use FRC as primary clock an use LPRC  only for TIMER 1.

My questions are:
1) Do the LPRC clock still running during sleep mode stage?
2) Do I need to configure LPRC on OSCCON.NOSC  register or can I still keeping SPLL (FRC) set on OSCCON.NOSC register?  (maybe LPRC always run....).

3) Can the two clock work together? (FRC and LPRC).

4) Do I need to set OSCCON.SOSCEN =  1 ( Enable Secondary Oscillator) to activate LPRC clock or this bit is use only for external Clock? (SOSC)

Thanks in advance to all of you.. :-)
Ciao,
Sergio
#1

9 Replies Related Threads

    Mysil
    Super Member
    • Total Posts : 3667
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Pic32MX Using FRC and LPRC together. 2020/02/24 13:00:49 (permalink)
    4 (1)
    Hi,
    LPRC have nothing to do with Secondary Crystal Oscillator and OSCCON.SOSCEN control bit.
    LPRC is the oscillator for Watchdog Timer.
    When watchdog timer is enabled, LPRC is also enabled.
     
    When Watchdog Timer is enabled, and microcontroller is awake, watchdog timeout will cause processor Reset.
    However, when Watchdog timer is enabled, and microcontroller is in Sleep mode,
    watchdog timeout will cause Wakeup from sleep ( not reset).
     
    When Sleep mode is entered, FRC will stop, while LPRC will continue.
    Do not mess with OSCCON.NOSC  in connection with Sleep mode.
    There are some differences between PIC32MZ and PIC32MX device families,
    how watchdog wakeup is handled by hardware and Startup/Excption handling code.
     
    Read Datasheet.
     
        Mysil
     
     
    #2
    SergioR
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2019/01/01 04:00:30
    • Location: Italy
    • Status: offline
    Re: Pic32MX Using FRC and LPRC together. 2020/02/24 13:18:59 (permalink)
    0
    Thanks Mysil for your explanation.
    I'm taking advantage of your experience for better understanding.

    My need is to use Timer1, not WDT.
    For this reason I'd like to know how to manage LPRC.
    Is it always active?

    I saw in datasheet that TIMER1 can accept LPRC as clock input.

    So I'd like to use LPRC clock as input on TIMER1 in order to wake-up the microcontroller.

    Could I keep OSCCON.NOSC set for SPLL (FRC) and use LPRC for TIMER1 when sleep mode condition occur?
    Thanks a lot for sharing your knowledge.
    Ciao
    Sergio
    #3
    simong123
    Lab Member No. 003
    • Total Posts : 1374
    • Reward points : 0
    • Joined: 2012/02/07 18:21:03
    • Location: Future Gadget Lab (UK Branch)
    • Status: offline
    Re: Pic32MX Using FRC and LPRC together. 2020/02/24 15:23:13 (permalink)
    0
    SergioR
    I saw in datasheet that TIMER1 can accept LPRC as clock input.

    For which PIC32MX did you see that for? No MX's can run Timer1 from LPRC as far as I know (Just checked 1xx, 470 and 5xx/6xx/7xx datasheets).
    #4
    SergioR
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2019/01/01 04:00:30
    • Location: Italy
    • Status: offline
    Re: Pic32MX Using FRC and LPRC together. 2020/02/24 16:01:00 (permalink)
    0
    Hi Simong123,
    thank for your reply.
    Probably I misunderstood the datasheet, (as I said, I'm opposite than expert:-) )
    Anyway on datasheet PIC32MX1XX/2XX page 159 chapter 13.0 TIMER1 there is a timer block diagram.
    There is showed LPRC as option for external clock input.
    It is managed by T1CON.TECS register
    As I said, probably I misunderstood the datasheet, so, sorry in advance.
    Please let me know your thought.
    Hope to receive your feedback soon.
    Have a good day,
    Sergio
    #5
    SergioR
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2019/01/01 04:00:30
    • Location: Italy
    • Status: offline
    Re: Pic32MX Using FRC and LPRC together. 2020/02/24 16:02:47 (permalink)
    0
    Hi Simong123,
    thank for your reply.
    Probably I misunderstood the datasheet, (as I said, I'm opposite than expert:-) )
    Anyway on datasheet PIC32MX1XX/2XX page 159 chapter 13.0 TIMER1 there is a timer block diagram.
    There is showed LPRC as option for external clock input.
    It is managed by T1CON.TECS register
    As I said, probably I misunderstood the datasheet, so, sorry in advance.
    Please let me know your thought.
    Hope to receive your feedback soon.
    Have a good day,
    Sergio
    #6
    ric
    Super Member
    • Total Posts : 26159
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Pic32MX Using FRC and LPRC together. 2020/02/24 16:58:38 (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!
    #7
    ric
    Super Member
    • Total Posts : 26159
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Pic32MX Using FRC and LPRC together. 2020/02/24 17:18:23 (permalink)
    4 (1)
    Even the Family reference manual has no mention of any Timers using LPRC as the clock.
    http://ww1.microchip.com/...n/DeviceDoc/61105F.pdf

    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!
    #8
    simong123
    Lab Member No. 003
    • Total Posts : 1374
    • Reward points : 0
    • Joined: 2012/02/07 18:21:03
    • Location: Future Gadget Lab (UK Branch)
    • Status: offline
    Re: Pic32MX Using FRC and LPRC together. 2020/02/24 22:10:26 (permalink)
    5 (1)
    Found it. It's in the PIC32MX 1xx/2xx XLP manual.
    The LPRC and Timer1 will continue to operate in sleep mode, and can wake up the CPU.
    This does not apply to Deep Sleep mode. Only the DSWDT can be used to wake up the CPU from Deep Sleep.
    Note that the LPRC is horrendously inaccurate (+/-35%), so may not be much use if you need any sort of accuracy.
     
    Also note in future to specify the specific device when asking questions. There are many families of PIC32MX, each with different options. I had to look thru' 6 datasheets to find the right one.
    #9
    SergioR
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2019/01/01 04:00:30
    • Location: Italy
    • Status: offline
    Re: Pic32MX Using FRC and LPRC together. 2020/02/24 22:45:22 (permalink)
    0
    Ops, sorry to all for my inaccurate data.
    Really thanks for explanation and your feedback.
    I will consider if your or not use LPRC due to the low stability.
    I really appreciate the help of all of you.
    Ciao,,
    Sergio
    post edited by SergioR - 2020/02/25 00:07:43
    #10
    Jump to:
    © 2020 APG vNext Commercial Version 4.5