Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Enabling the PLL for INTOSC of PIC18F2620

Status
Not open for further replies.

psmll

Member level 4
Joined
Apr 9, 2007
Messages
74
Helped
4
Reputation
8
Reaction score
0
Trophy points
1,286
Activity points
1,803
intio67

Hi,

I'm trying to enable the PLL for the internal oscillator of the 18F2620, I did all that the datasheet says:

FOSC3:FOSC0 = 1001

PLLEN = 1

OSCCON<6:4> = 111

but the PIC don't enable the PLL :cry:

Do you know what is the problem?

Thanks
 

osctune

Some update:

I contacted Microchip, and no answer :-(

I searched and find people with the same problem, but no solution :cry:

Some people simple say that the PLL don't work with the internal oscillator, even if the datasheet says it.

For me is hard to believe that datasheet says it, and it simple didn't work, but until I see it working I will have to believe that Microchip needs to pay more attention about it's products and what is written in datasheet, because even if it really works, the datasheet is incomplete, since I did all it says to do to enable the PLL, and it is not enabled.
 

pic intosc

The solution is to use the PRIMARY OSC block by setting OSCCON <1:0> to 00.

FOSC<4:0> settings at 1001 or 1000, and set the PLLEN bit in OSCTUNE<6>.

I tested the following mikroBasic code on a 18F4525 and delays based on 32MHz... it works!

Code:
main:

   TRISB = 0
   LATB = 0
   
   ADCON1 = 15               ' disable ADC's
   CMCON = 7                 ' disable Comparators
   
   OSCCON = %01110000        ' 8MHz using Primary Int Osc
   OSCTUNE.6 = 1             ' PLL Enabled for internal osc

   While true
      LATB = Not(LATB)       ' toggle PORTB LED's
      Delay_ms(500)
   Wend

end.
 

    psmll

    Points: 2
    Helpful Answer Positive Rating
pic24 pll osccon

I've used INTOSC and PLL too (for 32 MHz). Works fine.

Here's an Assembler example;
Code:
;
;  setup configuration fuses
;
        config  OSC = INTIO67   ; INTOSC, RA6 and RA7 I/O
        config  FCMEN = OFF     ; fail-safe clock monitor disabled
        config  IESO = OFF      ; oscillator switchover disabled
        config  PWRT = ON       ; power up timer on
        config  BOREN = OFF     ; brown out reset enable on
        config  BORV = 0        ; brown out reset voltage max
        config  WDT = OFF       ; watch dog timer disabled
        config  WDTPS = 16      ; watch dog timer prescaler
        config  MCLRE = ON      ; MCLR pin enabled
        config  LPT1OSC = OFF   ; low power TMR1 osc disabled
        config  PBADEN = OFF    ; PORTB<4:0> pins digital on reset
        config  CCP2MX = PORTC  ; CCP2 I/O multiplexed with RC1
        config  STVREN = OFF    ; stack full/underflow causes reset
        config  LVP = OFF       ; low voltage programming disabled
        config  XINST = OFF     ; extended instructions disabled
        config  DEBUG = OFF     ; background debug off
Code:
;
Boot1   movlw   b'01110000'     ; value for 8-MHz INTOSC
        movwf   OSCCON          ;
        bsf     OSCTUNE,PLLEN   ; enable 4x PLL for 32-MHz
Stable  btfss   OSCCON,IOFS     ; INTOSC frequency stable?
        bra     Stable          ; no, branch, else, continue
;
 

pic18f2620 internal oscillator

xorcise said:
The solution is to use the PRIMARY OSC block by setting OSCCON <1:0> to 00.

FOSC<4:0> settings at 1001 or 1000, and set the PLLEN bit in OSCTUNE<6>.

I tested the following mikroBasic code on a 18F4525 and delays based on 32MHz... it works!

hi, xorcise

I tested it (OSCCON <1:0> to 00) on my PIC18F2620, but no result, also at 8MHz :cry:

Added after 5 minutes:

Mike said:
I've used INTOSC and PLL too (for 32 MHz). Works fine.

hi, Mike, K8LH

I tested with your code, and my PIC continue at 8MHz :cry:

You tested in a PIC18F2620?

If yes, what is the revision?

Added after 8 minutes:

Mike said:
I've used INTOSC and PLL too (for 32 MHz). Works fine.

Here's an Assembler example;
Code:
(...)
        bcf     OSCTUNE,PLLEN   ; enable 4x PLL for 32-MHz
(...)

Hummm, for I can see your code is wrong, should be:

bsf OSCTUNE, PLLEN

Added after 4 minutes:

some, update:
seems that I'm getting 32MHz :D

I think, that is a problem with the configs, I will investigate and tell the results ;-)

Added after 1 hours 12 minutes:

Ok, finally works well :D

The problem is really the SCS1:SCS0 bits, I was wrong.

Note that microchip says in the datasheet 39626C.pdf:

Code:
bit 1-0 SCS1:SCS0: System Clock Select bits
1x = Internal oscillator block
01 = Secondary (Timer1) oscillator
00 = Primary oscillator

So since I wanted to use the "Internal oscillator block", the datasheet says to use "1x", but it's wrong, like xorcise said, to work it need to be "00", that datasheet says that is to "Primary oscillator"...

For me, this is really stupid...

Some code that work with 18F2620:
Code:
	LIST P=18F2620
	#include P18F2620.INC

	CONFIG	OSC = INTIO67, WDT = OFF, MCLRE = OFF
	
	ORG		0x0000
	goto	Main

	ORG		0x002A
Main
	movlw	b'01110000'
	movwf	OSCCON
	bsf		OSCTUNE, PLLEN

IntOscOK
	btfss	OSCCON, IOFS
	goto	IntOscOK
        
        ; you code where

	END

The IntOscOK loop is only need if the first code that PIC run need the oscillator to be stable ;-)
 

pic18f2620 oscillator

Sorry. As you have discovered, it should be bsf OSCTUNE,PLLEN...

Happy to hear you've got it working...

Regards, Mike
 

mikrobasic internal 8 mhz

Mike said:
Sorry. As you have discovered, it should be bsf OSCTUNE,PLLEN...

Happy to hear you've got it working...

Regards, Mike

I'm probably I bit more happy than you ;-) :D

I don't use this PICs (ex 18f2620) for final products because of €€ $$, but are very nice to some home projects or to produce a first prototype that works in a small time (ex using C language), them that it's working I know better how powerful the a PIC should to be and what peripherals are needed in the final product :D
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top