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

dspic33fj256mc710 PLL works in reverse!

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



Joined: 20 May 2015
Posts: 18

View user's profile Send private message

dspic33fj256mc710 PLL works in reverse!
PostPosted: Fri Oct 14, 2016 4:44 am     Reply with quote

Hi Everyone!

It's simple. I've configured my dspic33fj256mc710 to run in higher clocks with external crystal which is 8MHz. But when I use the pll, it just works reversely! I mean, if I use it in 40MIPS mode, it becomes ten times slower. If I use the internal clock everything is fine but by using an external crystal, it's just a mess.
The code is not a big deal:
Code:

#include <33FJ256MC710.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOJTAG                   //JTAG disabled

#device ICSP=1
#use delay(clock=80000000,crystal=8000000)


I've not seen such a thing with other chips.

Any Idea?

Bests.


Last edited by AlPicCss73 on Fri Oct 14, 2016 11:35 pm; edited 3 times in total
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Fri Oct 14, 2016 5:15 am     Reply with quote

Quote:
with external oscillator which is 8MHz


No, you have configured it to run with an external 8MHz crystal, not an oscillator.

The PLL is dividing the crystal/oscillator/whatever-it-really-is signal down. Your primary clock source is almost certainly not running. Instead the PIC is defaulting to a secondary clock source, probably by the failsafe clock monitor. Im short it's running off its internal 8Mhz clock, giving 4MIPS rather than your expected 40.
AlPicCss73



Joined: 20 May 2015
Posts: 18

View user's profile Send private message

PostPosted: Fri Oct 14, 2016 6:46 am     Reply with quote

Oops! I did a mistake in the text. I'm using an external crystal not an oscillator. Sorry about that. I've corrected it.
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Fri Oct 14, 2016 6:58 am     Reply with quote

Thing is there is no clock figure in the setup.
You need:

#use delay(clock=80000000,crystal=8000000)

internal=xxxx sets the chip up to use the internal oscillator to give the target frequency. It really ought to warn that you have two conflicting settings here, but oscillator checking is an area where CCS never warn (so you can select half a dozen different oscillators at the same time on some chips)...

For a crystal, you need to tell it the crystal frequency, and the target clock frequency, so it can setup the PLL.
AlPicCss73



Joined: 20 May 2015
Posts: 18

View user's profile Send private message

PostPosted: Fri Oct 14, 2016 7:59 am     Reply with quote

I've tested the
Code:
#use delay(clock=80000000,crystal=8000000)

Actually this code is the real problem here, when I want to modify the clock. It reduces the speed reversely. I'm really confused by it.
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Fri Oct 14, 2016 8:20 am     Reply with quote

Are you sure your crystal is actually working?.

It'd do what you describe if it wasn't.

Since you have CKFSM enabled, if the crystal wasn't working, it'd fall back to the internal oscillator.
Now if you specify (say) the clock to be 40Mhz, when it drops back to the internal oscillator it'd be running at 1/5th the speed it should (40/7.37). However if you specify 80MHz, it'd then run at 1/10th the speed it should (80/7.37) etc..

So the higher the clock you specify, the slower it'd seem to be running (it'd actually be running at the same speed, but the loop counts used for delays etc., would all be higher, making it look slower)....

What compiler version are you on?.
Reason is that on older compilers you had to explicitly enable the primary oscillator. Just setting the clock statement, did not actually setup the oscillator. So you needed to add the XT, PR_PLL fuses.

Have you got the start-up resistor across the crystal?.
Note under Figure 9-1 in the data sheet (the crystal won't reliably start without this).

Are you aware that this is listed as 'not suitable for new designs'?. You should be using the 33FJ256MC710A.
AlPicCss73



Joined: 20 May 2015
Posts: 18

View user's profile Send private message

PostPosted: Fri Oct 14, 2016 9:24 am     Reply with quote

I don't understand what's going on!
I knew that it is listed as 'not suitable for new designs', but that was the only choice for me. I've searched the topics and found someone has done it before but it was with an older version of the compiler. I used Ver.5.049 . I'm totally confused.
I never use start-up resistor (and so there was no problem) and in this case the crystal does not work totally not just correctly.

Bests
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Fri Oct 14, 2016 10:44 am     Reply with quote

A lot of crystals will not start at all on this chip without the resistor. This is why the data sheet (for this particular chip), has it as 'required'.....
AlPicCss73



Joined: 20 May 2015
Posts: 18

View user's profile Send private message

PostPosted: Fri Oct 14, 2016 2:33 pm     Reply with quote

I doubt it, but I'll give it a try.

Thanks a lot!
AlPicCss73



Joined: 20 May 2015
Posts: 18

View user's profile Send private message

PostPosted: Fri Oct 14, 2016 11:37 pm     Reply with quote

It was all because a little tiny solder, connected the OSC1 to the vcc directly!

Thanks guys.
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