CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Trying to get the 4620's PLL to work with the internal clock

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 29, 2009 9:28 pm     Reply with quote

This program works.
Code:
#include <18F4620.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=32000000) 

//====================================
void main()
{

setup_oscillator(OSC_32MHZ | OSC_PLL_ON);   

while(1)
  {
   output_high(PIN_B0);
   delay_ms(500);
   output_low(PIN_B0);
   delay_ms(500);
  }     

}
C Turner



Joined: 10 Nov 2003
Posts: 40
Location: Utah

View user's profile Send private message

Trying to get the 4620's PLL to work with the internal clock
PostPosted: Thu Apr 30, 2009 10:22 am     Reply with quote

I see the problem: You *can't* turn on OSCCON bits 0 or 1 and expect it to work. In other words, "Primary Oscillator" should be enabled, and NOT "Internal Oscillator Block."

Somehow, if you wanted to use the "Internal Oscillator Block" with the PLL, I'd have thought one might turn it on.

Stupid me!

Thanks for the help, PCM,

CT
hobiadami



Joined: 17 Oct 2006
Posts: 35
Location: City of Concrete

View user's profile Send private message Visit poster's website ICQ Number

pin change
PostPosted: Thu Apr 26, 2012 3:18 pm     Reply with quote

can't I use the oscillator pins as I/O with this setup?

I've used the code above on real hardware just by changing the pin numbers to pin_a6 or a7 and didn't be able to blink a led connected to those pins.

I'm using 4.114
_________________
www.endtas.com
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 26, 2012 5:28 pm     Reply with quote

Post your small compilable test program.
hobiadami



Joined: 17 Oct 2006
Posts: 35
Location: City of Concrete

View user's profile Send private message Visit poster's website ICQ Number

code
PostPosted: Fri Apr 27, 2012 12:59 am     Reply with quote

Thanks for the reply,

The program is absolutely same as yours. I just changed the output pin. A6 and A7, didn't change anything. Other pins are okay. Only the oscillator pins don't blink the led. I've tested with a brand new 18F4620 as well.

Code:

#include <18F4620.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=32000000) 

//====================================
void main()
{

setup_oscillator(OSC_32MHZ | OSC_PLL_ON);   

while(1)
  {
   output_high(PIN_A6);
   delay_ms(500);
   output_low(PIN_A6);
   delay_ms(500);
  }     

}

_________________
www.endtas.com
Ttelmah



Joined: 11 Mar 2010
Posts: 19503

View user's profile Send private message

PostPosted: Fri Apr 27, 2012 4:04 am     Reply with quote

Change to:
Code:

#include <18F4620.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=32000000)

//====================================
void main(void) {

   setup_oscillator(OSC_32MHZ | OSC_INTRC);   

   while(TRUE) {
      output_high(PIN_A6);
      delay_ms(500);
      output_low(PIN_A6);
      delay_ms(500);
  }     
}


This is one of those nasty little 'compiler version' ones.
First, OSC_32_MHZ, includes the PLL_ON bit, Doesn't matter to duplicate it, but doesn't actually do anything.
However key is that on some compilers, the OSC_xxMHz settings, for the two PLL modes, don't have the select to say 'use the internal oscillator'. When the PLL is selected, the internal oscillator is not defined as the primary oscillator (oddity of the chip...), so if you use them without specifying this, they switch to 'OSC_NORMAL', which then doesn't work, and the chip stops. Hence then your pin doesn't toggle....

Best Wishes
hobiadami



Joined: 17 Oct 2006
Posts: 35
Location: City of Concrete

View user's profile Send private message Visit poster's website ICQ Number

:)
PostPosted: Sat Apr 28, 2012 1:35 pm     Reply with quote

Thanks Thelmah, this solved it.
_________________
www.endtas.com
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group