10.07.2015 Views

pic24fj128ga010 family - Microchip

pic24fj128ga010 family - Microchip

pic24fj128ga010 family - Microchip

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PIC24FJ128GA010 FAMILYA recommended code sequence for a clock switchincludes the following:1. Disable interrupts during the OSCCON registerunlock and write sequence.2. Execute the unlock sequence for the OSCCONhigh byte, by writing 78h and 9Ah toOSCCON in two back-to-backinstructions.3. Write new oscillator source to the NOSC controlbits in the instruction immediately following theunlock sequence.4. Execute the unlock sequence for the OSCCONlow byte by writing 46h and 57h toOSCCON in two back-to-back instructions.5. Set the OSWEN bit in the instruction immediatelyfollowing the unlock sequence.6. Continue to execute code that is not clocksensitive (optional).7. Invoke an appropriate amount of software delay(cycle counting) to allow the selected oscillatorand/or PLL to start and stabilize.8. Check to see if OSWEN is ‘0’. If it is, the switchwas successful. If OSWEN is still set, thencheck the LOCK bit to determine cause offailure.The core sequence for unlocking the OSCCON registerand initiating a clock switch is shown in Example 7-1.EXAMPLE 7-1:BASIC CODE SEQUENCEFOR CLOCK SWITCHING;Place the new oscillator selection in W0;OSCCONH (high byte) Unlock SequenceMOV#OSCCONH, w1MOV#0x78, w2MOV#0x9A, w3MOV.b w2, [w1]MOV.b w3, [w1];Set new oscillator selectionMOV.b WREG, OSCCONH;OSCCONL (low byte) unlock sequenceMOV#OSCCONL, w1MOV#0x46, w2MOV#0x57, w3MOV.b w2, [w1]MOV.b w3, [w1];Start oscillator switch operationBSET OSCCON, #0DS39747E-page 100© 2009 <strong>Microchip</strong> Technology Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!