• AVR Freaks

Hot!PIC24F oscillator stop

Author
JanMetos
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2014/11/19 05:13:04
  • Location: 0
  • Status: offline
2020/07/03 00:32:00 (permalink)
0

PIC24F oscillator stop

Hi all,
 
i encountered a problem with waking up of PI24FJ1024GB606 mcu.
I executed many tested, and after investigations i found that mcu doesn't wake up sometimes. Then the mcu hangs until i do power-on reset. There is no problem in RTCC (which i am using for wake up), because i have connected an external pushbutton and this doesn't work as well then.
 
I am using 8MHz primary oscillator mode with PLL all the time. Whatchdog is enabled, so i would expect if waking up process fails watchdog should reset the mcu. But nothing.
 
My configuration settings:
 
// FSEC
#pragma config BWRP = OFF // Boot Segment Write-Protect bit (Boot Segment may be written)
#pragma config BSS = DISABLED // Boot Segment Code-Protect Level bits (No Protection (other than BWRP))
#pragma config BSEN = OFF // Boot Segment Control bit (No Boot Segment)
#pragma config GWRP = OFF // General Segment Write-Protect bit (General Segment may be written)
#pragma config GSS = DISABLED // General Segment Code-Protect Level bits (No Protection (other than GWRP))
#pragma config CWRP = OFF // Configuration Segment Write-Protect bit (Configuration Segment may be written)
#pragma config CSS = DISABLED // Configuration Segment Code-Protect Level bits (No Protection (other than CWRP))
#pragma config AIVTDIS = OFF // Alternate Interrupt Vector Table bit (Disabled AIVT)
// FBSLIM
#pragma config BSLIM = 0x1FFF // Boot Segment Flash Page Address Limit bits (Boot Segment Flash page address limit)
// FOSCSEL
#pragma config FNOSC = PRIPLL // Oscillator Source Selection (Primary Oscillator with PLL module (XT + PLL, HS + PLL, EC + PLL))
#pragma config PLLMODE = PLL96DIV2 // PLL Mode Selection (96 MHz PLL. (8 MHz input))
#pragma config IESO = ON // Two-speed Oscillator Start-up Enable bit (Start up device with FRC, then switch to user-selected oscillator source)
// FOSC
#pragma config POSCMD = XT // Primary Oscillator Mode Select bits (XT Crystal Oscillator Mode)
#pragma config OSCIOFCN = ON // OSC2 Pin Function bit (OSC2 is general purpose digital I/O pin)
#pragma config SOSCSEL = ON // SOSC Power Selection Configuration bits (SOSC is used in crystal (SOSCI/SOSCO) mode)
#pragma config PLLSS = PLL_PRI // PLL Secondary Selection Configuration bit (PLL is fed by the Primary oscillator)
#pragma config IOL1WAY = OFF // Peripheral pin select configuration bit (Allow multiple reconfigurations)
#pragma config FCKSM = CSECMD // Clock Switching Mode bits (Clock switching is enabled,Fail-safe Clock Monitor is disabled)
// FWDT
#pragma config WDTPS = PS8192 // Watchdog Timer Postscaler bits (1:8,192)
#pragma config FWPSA = PR128 // Watchdog Timer Prescaler bit (1:128)
#pragma config FWDTEN = ON_DIS_SLEEP // Watchdog Timer Enable bits (WDT Enabled only while device is active (disabled in sleep, SWDTEN disabled))
#pragma config WINDIS = OFF // Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode)
#pragma config WDTWIN = WIN25 // Watchdog Timer Window Select bits (WDT Window is 25% of WDT period)
#pragma config WDTCMX = WDTCLK // WDT MUX Source Select bits (WDT clock source is determined by the WDTCLK Configuration bits)
#pragma config WDTCLK = LPRC // WDT Clock Source Select bits (WDT uses LPRC)
// FPOR
#pragma config BOREN = ON // Brown Out Enable bit (Brown Out Enable Bit)
#pragma config LPCFG = ON // Low power regulator control (Retention Sleep controlled by RETEN)
#pragma config DNVPEN = ENABLE // Downside Voltage Protection Enable bit (Downside protection enabled using ZPBOR when BOR is inactive)
// FICD
#pragma config ICS = PGD1 // ICD Communication Channel Select bits (Communicate on PGEC1 and PGED1)
#pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled)
#pragma config BTSWP = OFF // BOOTSWP Disable (BOOTSWP instruction disabled)
// FDEVOPT1
#pragma config ALTCMPI = DISABLE // Alternate Comparator Input Enable bit (C1INC, C2INC, and C3INC are on their standard pin locations)
#pragma config TMPRPIN = OFF // Tamper Pin Enable bit (TMPRN pin function is disabled)
#pragma config SOSCHP = OFF // SOSC High Power Enable bit (valid only when SOSCSEL = 1 (Enable SOSC low power mode)
#pragma config ALTVREF = ALTREFEN // Alternate Voltage Reference Location Enable bit (VREF+ and CVREF+ on RA10, VREF- and CVREF- on RA9)
 
Simple Routine of going into the sleep mode:
 
Sleep(); // Sleep mode running
rt_delay10us(1);
CLRWDT(); // Clear watchdog
 
 
I tried to disable PLL and change socillator to FRC before going into the sleep mode:
 
// Clock switching to Primary Oscillator
ALL_INTS_DISABLE();
__builtin_write_OSCCONH(0x00); // Initiate Clock Switch to FRC with PLL (NOSC=0b001)
if(_OSWEN == 0)
{ // Check clock switch is not in progress
__builtin_write_OSCCONL( (OSCCONL & 0x42) | 0x01); // Start clock switching
}
while (_COSC != 0b000); // Wait for Clock switch to occur
ALL_INTS_ENABLE();
rt_delay10us(10);
 
Sleep(); // Sleep mode running
rt_delay10us(1);
CLRWDT(); // Clear watchdog
 
// Clock switching to Primary Oscillator with PLL module
ALL_INTS_DISABLE();
rt_delay10us(50);
__builtin_write_OSCCONH(0x03); // Initiate Clock Switch to FRC with PLL (NOSC=0b001)
if(_OSWEN == 0)
{ // Check clock switch is not in progress
__builtin_write_OSCCONL( (OSCCONL & 0x42) | 0x01); // Start clock switching
}
while (_COSC != 0b011); // Wait for Clock switch to occur
ALL_INTS_ENABLE();
rt_delay10us(10);
 
 
But the same result.
And it happens mostly in lower temperatures, below 0 or mostly -10 degrees.
 
Do you have any idea if there is needed a workaround in the handling of oscillator? I didn't found nothing significant in errata sheet.
The bad is that watchdog doesn't help in this case.
 
Thank you
#1

4 Replies Related Threads

    mbrinks
    Starting Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2011/05/03 04:57:32
    • Location: Denmark
    • Status: offline
    Re: PIC24F oscillator stop 2020/07/09 08:35:19 (permalink)
    0
    Hello
     
    Could the problem be that the oscillator isn't running (or starting) at low temperatures?
    Have you measured the oscillator (OSCO) when the problem occurs?
    Actually, putting a probe on OSCI / OSCO pins can be a bad thing, because the probe capacitance will affect the oscillator (for better or worse). A better way to check the oscillator is to enable the REFO module, map the output to a free IO pin, and then measure at that pin.
     
    Another way of testing could be to remove the primary crystal and replace it with an external oscillator - a component or even a bench frequency generator. Remember to change oscillator configuration to "EC".
    If the problem disappears when using an external oscillator, then it's likely that the problem is the crystal oscillator.
     
    Best Regards,
    Michael
    #2
    JanMetos
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2014/11/19 05:13:04
    • Location: 0
    • Status: offline
    Re: PIC24F oscillator stop 2020/07/10 06:49:35 (permalink)
    4 (1)
    Hi,
     
    yes, it is difficult to test oscillator on OSCO/OSCI. But the same it is difficult to measure by temperature below 0 degrees, now when we have middle of summer here. :) But if you mean just to verify if clock is working, i made LED blinking after wake up. After CPU stopped (didn't wake up anymore) there is no LED blinking anymore.
     
    I tested it not only with primary crystal, but with internal FRC oscillator as well. But it is true, after wake up i switched clock back to PRI+PLL oscillator.
     
    I am going to do more experiments, i will completely disable PRI and PLL and run the CPU only with FRC oscillator.
     
    Can not be this issue related to low power sleep mode?
    #3
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3984
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: PIC24F oscillator stop 2020/07/10 12:39:52 (permalink)
    1 (2)
    If you config WDOG to OFF, it can be controlled manually.
    #pragma config FWDTEN = OFF
     
    By setting SWDTEN, the WDT counts until zero,
    wakes cpu, the program then turns off the led and sleeps.
     
    It also wakes on INT0 - an interrupt from a nRF24L01+ device.
     
     
        RCONbits.SWDTEN = led_reminder;
        Sleep();  
     
       // code wakes, decides if wdto or interrupt.
     
     
    This wakes up the cpu.
     
    void __attribute__ ((interrupt, no_auto_psv)) _INT0Interrupt(void) {
        IFS0bits.INT0IF = 0;      // wake from sleep
    }
    // ----------------------------------------------------



    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.
    #4
    JanMetos
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2014/11/19 05:13:04
    • Location: 0
    • Status: offline
    Re: PIC24F oscillator stop 2020/07/15 04:38:48 (permalink)
    0
    Hi all,
     
    I tested my device with PIC24FJ1024G606 again. There are setup RTC module interrupt every 5 min. and enabled external interrupt INT1 (with pushbutton) and enabled USB interrupt. Normally everything works.
    It was running approx. 5 hours (every 5 min. wake up for a few seconds), then suddenly stopped again.
     
    Status after the device stopped:
    VDD =  3V
    VCap = 1.8V
    SOSC still running for RTC module (checked with scope, 32kHz)
     
    the cpu could not be woken up anymore :
    - from RTC module
    - from external INT (push-button)
    - from attached USB
    Even I tried to reset the CPU through MCLR (pulling down to 0) many times, but i could not reset it.
     
    Only Power-on reset helps (when i unplugged battery and plugged back).
     
    Did anyone work with PIC24 (PIC24FJxxxGxxxx) ? Can you provide me configuration bits or working sleep mode handler and oscillator setting ?
    I tested my device a few times, it has been stopped always in a 2 hours, 5 hours or 20 hours ... 
     
    #5
    Jump to:
    © 2020 APG vNext Commercial Version 4.5