Change your last config line to;
@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _DEBUG_OFF_4L & _XINST_OFF_4L
You'll also want to write to OSCCON since it does not default to 8MHz.
Change your last config line to;
@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _DEBUG_OFF_4L & _XINST_OFF_4L
You'll also want to write to OSCCON since it does not default to 8MHz.
Bruce,
thanks loads! your correction worked. i didn't know what that fuse did but now i guess i can see the results.
what about utilizing the x4 PLL feature with the internal osc? i've tried setting OSCTUNE.6=1 but i don't see a difference.
am i supposed to tell PBP that i'm now 32MHz with the DEFINE OSC 32 statement instead of DEFINE OSC 8?
thanks again!
-=drew
_XINST_OFF_4L disables extended instruction set, which you'll always want disabled on any 18F part that has it when using PBP.
The unprogrammed default for this bit is ON unless you disable it as shown above.
Hint: Look in your default PBP header file for what they show there.
Yes. If the PIC is operating at 32MHz, then you'll want to define it just like you would for any osc speed.
Write the value 'shown in your datasheet' to OSCCON to set it for 8MHz. Then flip the bit in OSCTUNE to enable PLL. It should then be running at 32MHz.
Bruce,
i tried setting the OSCCON value and the OSCTUNE bit as well but i'm not getting the higher speed. here's my test code:
'use the following when using the MPASM assembler
@ __CONFIG _CONFIG1H, _OSC_INTIO67_1H
@ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOREN_OFF_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H
@ __CONFIG _CONFIG3H, _MCLRE_ON_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _DEBUG_OFF_4L & _XINST_OFF_4L
@ __CONFIG _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L
DEFINE OSC 32
clear
OSCCON=%11111110 'SLEEP mode, 8MHz internal osc, no startup but use primary, primary has stablized, select internal osc block
OSCTUNE.6=1 'enables PLL 4x speed multipler for the internal OSC
ADCON1=%00001111 'turns all AD pins to digital and tells module to use Vdd and Vss
ADCON0.0=0 'disables AD module
TRISB=%00000000 'PortB.4 => Heartbeat LED pin set to output
HBLED var PORTB.4 'alias for heartbeat LED
;------------------------------------------------------------------------
Main:
toggle hbled
pause 500
GOTO Main
;------------------------------------------------------------------------
when i use DEFINE OSC 8 the LED flashes as expected. when use DEFINE OSC 32 it flashes slowly which leads me to think i've not successfully activated the x4 PLL.
-=drew
Hi Drew,
Try changing OSCCON=%11111110 to OSCCON=%11111100. The internal osc is the primary
osc in this configuration since you have it set in your config option. I.E. the intrnal osc is
now considered the primary oscillator.
If you had your config osc setting set for an external osc, then you could switch between
the primary (external osc) & internal osc by setting SCS.1.
Also note that OSCCON bits 2 & 3 are read only, so attempting to write to these bits is not
needed, and, of course, doesn't really change a bit. These bits are read-only and pretty
much just for you to read to determin the oscillator status.
Only registers that show R/W-x are readable/writeable. The x just signifies the default
value of the register bit at POR.
reading the OSCCON configuration was indeed a bit (pardon the pun) confusing because i thought i was selecting the internal osc by setting osccon.1 and osccon.0 to 1x. thanks for straightening me out. i've tested it and it does indeed work.
thanks again everyone (especially Bruce)!
now i'm running 32Mhz off of an internal osc. that's awesome!
-=drew
Bookmarks