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 support@ccsinfo.com

PIC16F1718 Oscillator

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



Joined: 25 Oct 2004
Posts: 136

View user's profile Send private message

PIC16F1718 Oscillator
PostPosted: Tue Oct 06, 2015 12:31 pm     Reply with quote

Hello Friends

I'm changing the PIC to the PIC16F1718 and having trouble with the oscillator settings.

I am doing this:
Code:

#use delay(clock=8000000)

void main()
{
setup_oscillator(OSC_8MHZ| OSC_INTRC );
output_low(Mode);

while(TRUE)
  {
   output_low(LED1);
   output_low(Mot1A);
   delay_ms(100);
   output_high(Mot1A);
   output_high(LED1);
   delay_ms(100);
  }
}

This will create a perfect 100ms output pulse !

BUT when changing to this:
Code:
#use delay(clock=32000000)
setup_oscillator(OSC_8MHZ| OSC_INTRC | OSC_PLL_ON); 

I get a 400ms output pulse !

BUT this works also ok !
Code:
#use delay(clock=16000000)
setup_oscillator(OSC_16MHZ| OSC_INTRC ); 

Any idea what I am doing wrong ?

Best regards
Andreas
Ttelmah



Joined: 11 Mar 2010
Posts: 19448

View user's profile Send private message

PostPosted: Tue Oct 06, 2015 1:11 pm     Reply with quote

Look at the oscillator diagram.
Note how if you select the PLL, the input that needs to be selected using SCS1:0, is the '00' OSC input (the normal oscillator input), _not_ the internal oscillator input!.

You can't retro select this if you have booted with another primary oscillator. It has to be setup as the primary oscillator.
Andreas



Joined: 25 Oct 2004
Posts: 136

View user's profile Send private message

PostPosted: Tue Oct 06, 2015 11:52 pm     Reply with quote

Hello Ttelmah

Thank you for the fast reply!

I found one mistake, I was setting the FUSE RC at the beginning, so I couldn't change the osc type.

I tried your suggestion, but this gives me a 400ms Delay ????:
Code:

#use delay(clock=32000000)

setup_oscillator(OSC_8MHZ| OSC_NORMAL | OSC_PLL_ON);

It looks like the PLL is not enabled.

One idea more ???

best regards
Andreas
Ttelmah



Joined: 11 Mar 2010
Posts: 19448

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 1:37 am     Reply with quote

You need the INTRC_IO fuse. This should work:

Code:

#include <16F1718.h>
#fuses INTRC_IO
#fuses NOWDT
#fuses NOMCLR
#fuses NOWDT
#fuses NOCLKOUT
#fuses NOLVP

#use delay (INTERNAL=32MHz)

void main(void)
{
setup_oscillator(OSC_8MHZ| OSC_NORMAL | OSC_PLL_ON); 
while(TRUE)
  {
   output_toggle(PIN_A0);
   delay_ms(100);
  }
}


Basically if you look at figure 6-1 in the data sheet, you need the line that gives PRIMUX=1, and PLLMUX=1. This only happens when you have OSCCON=0b11110000, and FOSC<2:0> (in the config fuses) has to be 0b100. I've compiled this, and it sets both these registers correctly on the current compilers.
Andreas



Joined: 25 Oct 2004
Posts: 136

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 4:18 am     Reply with quote

Hello Ttelmah

Thanks a lot for your suggestion, that was the trick !!!

It looks that in the CCS Compiler this is not covered with the OSC settings line.

For my opinion this should be automatically set if I want 8Mhz with 4x PLL.

Many thanks and best regards.
Andreas
Ttelmah



Joined: 11 Mar 2010
Posts: 19448

View user's profile Send private message

PostPosted: Wed Oct 07, 2015 4:29 am     Reply with quote

It is difficult, since most CPU's that allow this, allow it either to be fully setup in the fuses, or at run time. It's an 'awkwardness' that instead on this CPU it automatically selects this, only if all the other options are setup (this is the point about the diagram in the oscillator diagram), so you have to work out how to do all the settings shown. I'm sure once it's been around a little longer, it'll do it automatically if you just select 'internal=32MHz'. I'd suggest you point it out to CCS, and they'll probably implement it in the next release. Smile
Andreas



Joined: 25 Oct 2004
Posts: 136

View user's profile Send private message

PostPosted: Thu Oct 08, 2015 12:38 pm     Reply with quote

Hello Ttlemah

Thanks for Your help, it worls now in the correct frequency.

I will send a request to ccs about this Problem.

best regards
Andreas
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