• AVR Freaks

Hot!Unable to start secondary oscillator on PIC24F16K102

Author
peterg1000
Senior Member
  • Total Posts : 171
  • Reward points : 0
  • Joined: 2009/01/29 13:07:52
  • Location: Flamstead, Herts, UK
  • Status: offline
2020/02/17 10:16:57 (permalink)
0

Unable to start secondary oscillator on PIC24F16K102

Hi,
I am unable to set the OSCCON,#SOSCEN  bit on a prototype test board. The FOSC configuration is set as :-
 
// FOSC
#pragma config POSCMOD = HS            
#pragma config OSCIOFNC = OFF          
#pragma config POSCFREQ = HS           
#pragma config SOSCSEL = SOSCHP       
#pragma config FCKSM = CSDCMD         
 
Relevent part of initialisation is :-
;
    mov     #0x0010,w0        ; Set all GPIO pins as outputs except for SOSC pins
    mov     w0,TRISA            ;
    mov     w0,TRISB            ;
;
    bset    OSCCON,#SOSCEN        ; Enable secondary oscillator (32.768KHz)    ***This does nothing - bit not set!!!****
    bset    T1CON,#15          ; Enable T1
    bset    T1CON,#1            ; Clock timer from T1CK pin (SOSCO)
;

I must be doing something wrong in the configuration or initialisation, but can't see any thing obvious.  The SOSC power is set to high in case there was a faulty XTAL, but the fact that the SOSC enable bit cannot be set  seems to be the likely cause of the problem. The processor is operating and executing a micky-mouse programme.

Hope someone can lighten my darkness.
 
 
 
 
#1

3 Replies Related Threads

    MBedder
    Circuit breaker
    • Total Posts : 6841
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: Unable to start secondary oscillator on PIC24F16K102 2020/02/17 10:27:40 (permalink)
    5 (3)
    RTFM about special handling of the OSCCON register.
    #2
    _fragment_
    Super Member
    • Total Posts : 412
    • Reward points : 0
    • Joined: 2008/10/08 09:17:55
    • Location: Idaho
    • Status: offline
    Re: Unable to start secondary oscillator on PIC24F16K102 2020/02/17 10:35:57 (permalink)
    0
    In other words, you might need to do an unlock sequence first.
     
    Dave
    #3
    peterg1000
    Senior Member
    • Total Posts : 171
    • Reward points : 0
    • Joined: 2009/01/29 13:07:52
    • Location: Flamstead, Herts, UK
    • Status: offline
    Re: Unable to start secondary oscillator on PIC24F16K102 2020/02/17 12:49:23 (permalink)
    0
    Thanks for that advice - solved the problem.   
    Realise now that config only sets HP or LP for SOSC  - it isn't enabled, that has to be done separately when access is locked.   How perverse is that!!
     
    Thanks again guys - help appreciated
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5