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

CCS DSP Analog Dev Kit

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



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

CCS DSP Analog Dev Kit
PostPosted: Fri Mar 16, 2012 7:26 am     Reply with quote

I'm currently "playing" with this thing in order to learn the ropes of the dsPIC33 and it is perhaps the most frustrating board I've ever dealt with. The problem I'm having is that the oscillator won't consistently start. I can go several days with no issues, then have an equal number of days of nothing but trouble - with no changes to the oscillator code or fuses.

I've even tried changing the series resistor on the crystal circuit and the crystal caps - to no avail. I've found that a 1k resistor bridging Vcc (3.3V) and one leg of the crystal will always kick-start it, but that's a bit of a pain.

Here is the relevant part of the code:

Code:
#include <33FJ128GP706.h>

#FUSES NOWDT   
#FUSES PR_PLL
#FUSES HS
#FUSES CKSNOFSM
#FUSES PUT128
#FUSES ICSP1
#FUSES NOJTAG
#FUSES NODEBUG
#FUSES NOIESO

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


The board has a cheap 12 MHz crystal, and I'm using the PLL to run the processor at 80 MHz. The crystal has a series 330 ohm resistor, and the crystal caps are 15 pF. I've tried lowering that R to as low as 50 ohms, but I've found that it seems to be more reliable with an R of 270 ohms. I also tried swapping out the 15 pF caps with 22 pF, and I've also tried removing them entirely. It seems to be more stable with the original 15 pF caps, with the case of just one 15 pF cap removed coming a close second.

Am I setting the fuses correctly? Assuming the fuses are correct, when I migrate to a properly laid out PCB with a proper ground plane, will this issue go away? Is there a more robust way to get this thing to oscillate?

PCD version 4.129.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 12:05 pm     Reply with quote

I don't have any experience with the dsPic33 series, but I did a Google
search for this:
Quote:
site:microchip.com/forums dspic33 oscillator start OR start-up

and got this thread:
http://www.microchip.com/forums/m357107.aspx
See Fredmatic's reply. It may help.
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 1:42 pm     Reply with quote

Much appreciated PCM. It helped but startup still isn't as easy as it should be, as I still have to employ the pull-CLKIN-line-high trick to get it to start.

The PCB layout is not the best and the 12 MHz crystal CCS chose is not the best either.
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 4:56 pm     Reply with quote

I still have a hardware issue in that the resistor in the crystal circuit is too big, but I think I found the biggest issue. If you employ the internal/external clock switchover fix mentioned in the link above, you can't just write to the OSCCON register directly - there is an unlock procedure you must follow first. If anyone else is having this problem, consult the Oscillator portion of the dsPIC33 datasheet for the procedure.
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Mon Mar 19, 2012 9:03 am     Reply with quote

I hate this board despite the fact that I finally have it working quite reliably. For anyone facing this same problem, here is code that works (crystal = 12.000 MHz, PLL set to run the PIC at 80.000 MHz):

Code:
#include <33FJ128GP706.h>

#FUSES NOWDT
#FUSES FRC
#FUSES PR_PLL
#FUSES HS
#FUSES CKSNOFSM
#FUSES PUT128
#FUSES ICSP1
#FUSES NOJTAG
#FUSES NODEBUG

#use delay(internal=7370000)

#use fast_io(c)

void main(void) {
   setup_pll();
   while (TRUE) {
      // your code here
   }
}

void setup_pll(void) {
   output_c(0xc002); // this is for my particular application, yours may be different
   set_tris_c(0x1000); // I've found that "kicking" the crystal by setting
   // the CLKO line high initially seems to help to get the oscillator
   // to run
   delay_us(1);
   
   // M = 40, N1 = 3, N2 = 2
   // N1
   CLKDIV = 1; // PLLPRE
   // N2
   PLLPOST0 = 0;
   PLLPOST1 = 0;
   // M
   PLLFBD = 38;
   
   // following is from DS70186C.pdf
   #asm
   MOV #0x03, w0
   MOV OSCCONH, w1
   MOV #0x78, w2
   MOV #0x9A, w3
   MOV.B w2, [w1]
   MOV.B w3, [w1]
   MOV.B w0, [w1]
   
   MOV #0x01, w0
   MOV OSCCONL, w1
   MOV #0x46, w2
   MOV #0x57, w3
   MOV.B w2, [w1]
   MOV.B w3, [w1]
   MOV.B w0, [w1]
   #endasm
   
   while(OSCCON.cosc != 3); // wait for switchover to occur
   
   while (!OSCCON.lock); // wait for PLL to lock
   
   #use delay(clock=80000000,crystal=12000000) // this particular line does it all over again  - if anyone
   // can tell me how to let the compiler know what the clock frequency
   // is without allowing the compiler to re-set the clock all over again,
   // I'd appreciate it...but for now, it works and I'm grateful for that
   OSCCON.clklock = 1;
}
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