• AVR Freaks

Hot!Oscillator switching issue by lower temperature at PIC18F67J94

Author
JanMetos
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2014/11/19 05:13:04
  • Location: 0
  • Status: offline
2020/06/09 08:01:41 (permalink)
0

Oscillator switching issue by lower temperature at PIC18F67J94

Hi all,
 
i encountered an interesting and really annoying issue with clock switching in PIC18F67K94 cpu.
We made a device based on this chip PIC18F67K94 which is dedicated for use in outdoor environment in the fields, temperature range expected from -20 degrees to 50 degrees at least. We have this big issue in approx. 10 - 15 % of all devices currently.
The point is, due to USB driver i am using FRC with PLL oscillator as standard system clock source.
Due to errata document (page 3) when using 96 MHz PLL as system clock i need to switch off PLL and switch oscillator only to FRC without PLL before entry sleep mode. After exit from sleep mode i have to switch clock temporarily to FRC 500 kHz and switch back to FRCPLL again. I do.

On 85 - 90 % of our device it works good (in very wide temperature range, i have some in the freezer and without any problem). On the rest a watchdog reset is being executed after oscillator switching back to FRCPLL.
I did a lot of experiments and debugging process, I found out the problems happens only after that oscillator switching and only when ambient temperature is lower than 10 - 15 degrees Celsius (it is very different in among devices). The device is normally working in lower temperature (below zero as well), only rigth after osc switching the device stops to work and watchdog is being executed.
 
Errata document: http://ww1.microchip.com/downloads/en/DeviceDoc/80000551E.pdf
 
#1

8 Replies Related Threads

    JanMetos
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2014/11/19 05:13:04
    • Location: 0
    • Status: offline
    Re: Oscillator switching issue by lower temperature at PIC18F67J94 2020/06/09 08:05:22 (permalink)
    0
    My routine of entry and exit sleep mode:
     
    // Entry and exit from sleep mode using FRCPLL
    OSCCON2bits.CLKLOCK = 0; // Make sure clock switching is enabled
    OSCCON = 0x00; // Select the FRC 8MHz (without PLL) as the clock source
    Sleep(); // Enter Sleep mode. After device wakes up, temporarily clock switch to fixed FRC 500 kHz, before switching back to FRCPLL mode
    OSCCON2bits.CLKLOCK = 0; // Make sure clock switching is enabled
    OSCCON = 0x06; // After device wakes up, temporarily clock switch to fixed FRC 500 kHz, before switching back to FRCPLL mode. Make sure clock switch has taken effect, as indicated by COSC bits getting set to FRC 500 kHz 
    while((OSCCON & 0x70) != 0x60);
    OSCCON3 = 0x01; // Now clock switch back to the FRCPLL setting. Make sure 4 MHz is selected from FRC, since the 96 MHz PLL wants a 4 MHz input
    OSCCON = 0x01; // Request switch to FRCPLL output
    while((OSCCON & 0x70) != 0x10);
    CLRWDT(); // Clear Watchdog counter
    Delay1KTCYx(1);
     
     
    Does anybody have a clue what is wrong?
    I put there a various delays after each clock switching process, nothing helped. I just know after "while((OSCCON & 0x70) != 0x10);" the clock is probably working maybe 10 - 20 cycles, and then it hangs and my watchdog counter (32 seconds) resets the device. To remind you, this happens (not regularly, sometimes a few times in row, sometimes every second / third time) only if ambient temperature of PIC is lower than 15 degrees Celsius).
     
    I could not find any similar problem here, and errata document doesn't help as well.
    10 - 15 % is quite a lot by us when we talk about 1500 devices and we want to produce more.
     
    Thanks
    #2
    Nikolay_Po
    Super Member
    • Total Posts : 1941
    • Reward points : 0
    • Joined: 2012/04/01 13:49:27
    • Location: Russia, Novorossiysk
    • Status: offline
    Re: Oscillator switching issue by lower temperature at PIC18F67J94 2020/06/12 23:02:50 (permalink)
    +2 (2)
    Here:
     
    // Entry and exit from sleep mode using FRCPLL
    OSCCON2bits.CLKLOCK = 0; // Make sure clock switching is enabled
    OSCCON = 0x00; // Select the FRC 8MHz (without PLL) as the clock source
     
    //Are you sure the clock switching is finished before going to sleep?

    Sleep(); // Enter Sleep mode. After device wakes up, temporarily clock switch to fixed FRC 500 kHz, before switching back to FRCPLL mode

     
    I see none delay between oscillator configuration change and sleep command. With this example the controller may enter sleep mode before it completes clock switching.
    #3
    RISC
    Super Member
    • Total Posts : 5776
    • Reward points : 0
    • Status: offline
    Re: Oscillator switching issue by lower temperature at PIC18F67J94 2020/06/13 15:29:29 (permalink)
    0
    Hi,
    (please correct your first post : PIC18F67K94 does not exist...only PIC18F67J94)
    Regards
     
    post edited by RISC - 2020/06/14 02:34:26
    #4
    ric
    Super Member
    • Total Posts : 28299
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Oscillator switching issue by lower temperature at PIC18F67J94 2020/06/13 16:12:19 (permalink)
    +1 (1)
    That PIC has ACT (active clock tuning), so it should be locking the internal oscillator to the clock of the USB master whenever connected.
     

    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!
    #5
    RISC
    Super Member
    • Total Posts : 5776
    • Reward points : 0
    • Status: offline
    Re: Oscillator switching issue by lower temperature at PIC18F67J94 2020/06/14 02:34:02 (permalink)
    0
    Thanks RIC,
    I missed that point (ACT). I correct my post accordingly
    Regards
    #6
    JanMetos
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2014/11/19 05:13:04
    • Location: 0
    • Status: offline
    Re: Oscillator switching issue by lower temperature at PIC18F67J94 2020/06/15 01:57:27 (permalink)
    0
    Hi all,
     
    thanks for your comments.
     
    1.
    I am sorry, there should be PIC18F67J94 (as it is in the subject correctly).
     
    2.
    I posted example code (suggested from errata sheet). Later i put various delays before going into sleep mode and after wake up as well, experimentally. I am talking about delays 1 - 100 ms and more.
     
    Before sleep i was also waiting until clock switch done as well, e.g.:
     
    OSCCON2bits.CLKLOCK = 0;
    OSCCON = 0x00;
    while((OSCCON & 0x70) != 0x00);
    rt_delay1ms(100);
    Sleep();
     
    After sleep, e.g.
     
    OSCCON2bits.CLKLOCK = 0;
    OSCCON = 0x06;
    while((OSCCON & 0x70) != 0x60);
    rt_delay1ms(100);
     
     
    3. As i wrote, i found out the system hangs during clock switching.
    It measn it doesn't matter if i switch the clock right after wake up from sleep, or 10 seconds later. It hangs after closk switch from FRC to FRC+PLL.
     
    E.g. A led is being blinked after wake up from sleep long time (during FRC oscillator), until i try to switch clock FRC with PLL, then it hangs and station is being rebooted. I remind you, it happens by lower temperature (below 10 - 15 degrees Celsius) on 10 - 15 % of all products.
     
    Sleep();
    for(count = 0; count < 50; count++)
    {
       rt_delay1ms(50);
       _pinSet_LED = 1;
       rt_delay1ms(50);
       _pinSet_LED = 0;
    }
    OSCCON2bits.CLKLOCK = 0;
    OSCCON = 0x06;
    while((OSCCON & 0x70) != 0x60);
    rt_delay1ms(100);
    #7
    charlie0
    Starting Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2018/04/30 11:46:04
    • Location: 0
    • Status: offline
    Re: Oscillator switching issue by lower temperature at PIC18F67J94 2020/07/30 10:44:15 (permalink)
    0
    Hi JanMetos, have contacted Microchip support regarding this issue? 
    #8
    JanMetos
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2014/11/19 05:13:04
    • Location: 0
    • Status: offline
    Re: Oscillator switching issue by lower temperature at PIC18F67J94 2020/08/03 04:56:32 (permalink)
    0
    Hi charlie0,
     
    i didn't contact anyone from microchip support so far.
    I assume, something is wrong with external oscillator (crystal). Probably using the internal FOSC it is working better, without any issue. But i will test it more.
    #9
    Jump to:
    © 2020 APG vNext Commercial Version 4.5