I've got a 10MHz external crystal so to use the PLL I need to modify the PLLPRE and PLLPOST bits. Following the setup guidelines from microchip tells me that I need to modify the values and then switch from the internal RC (for example) to the external crystal with PLL.
Using the microchip supplied code to switch clock sources produces the following error: "Invalid ASM instruction(135): #OSCCONH"
The ASM code is:
Code: Select all
asm {
;Place the New Oscillator Selection (NOSC=0b011) in W0
MOV #0x13,W0
;OSCCONH (high byte) Unlock Sequence
MOV #OSCCONH, W1
MOV #0x78, W2
MOV #0x9A, W3
MOV.B W2, [W1] ; Write 0x78
MOV.B W3, [W1] ; Write 0x9A
;Set New Oscillator Selection
MOV.B W0, [W1]
; Place 0x01 in W0 for setting clock switch enabled bit
MOV #0x01, W0
;OSCCONL (low byte) Unlock Sequence
MOV #OSCCONL, W1
MOV #0x46, W2
MOV #0x57, W3
MOV.B W2, [W1] ; Write 0x46
MOV.B W3, [W1] ; Write 0x57
; Enable Clock Switch
MOV.B W0, [W1]
wait:
BTSC OSCCON, #0
BRA wait
};