dsPIC33FJ128GP802 internal oscillator settings

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

dsPIC33FJ128GP802 internal oscillator settings

Post by viki2000 »

I have tried a simple LED blink 1s on and 1s off with the settings from page 25 of “DS70216C - Section 39. Oscillator for dsPIC33F/PIC24H”:
http://ww1.microchip.com/downloads/en/D ... 70216C.pdf
It does not work properly. It blinks too fast.
That means improper settings for oscillator registers.
MCLR has 10K attached to it and Watchdog Timer disabled.
The VDD is 3.2Vdc. VCAP is 10uF ceramic multilayer. Decoupling is 100nF. I use the 28pin PDIP package.
FC7 is v 7.2.1. Below it is the simple code used.

Could you help with the proper internal oscillator settings?
dsPIC33FJ128GP802_LED.fcfx
LED blink
(8.64 KiB) Downloaded 210 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: dsPIC33FJ128GP802 internal oscillator settings

Post by Benj »

Hello,

We have code like this to configure the internal oscillator when using USB on the 16-bit PICs.

Maybe you need something like this in a C icon at the start of the program.

Code: Select all

          MX_UINT16 pll_startup_counter = 600;
          CLKDIVbits.PLLEN = 1;
          while(pll_startup_counter--);
LED flashing too fast means the chip is running faster then you have specified in the project options.

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: dsPIC33FJ128GP802 internal oscillator settings

Post by viki2000 »

dsPIC33FJ128GP802 Datasheet page 147 shows CLKDIV:
http://ww1.microchip.com/downloads/en/D ... 70292G.pdf

There is no PLLEN bit.

viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Re: dsPIC33FJ128GP802 internal oscillator settings

Post by viki2000 »

Here is the C code with the settings that makes the dsPIC33FJ128GP802 run at (close to) 80MHz with internal oscillator:

Code: Select all

CLKDIVbits.PLLPRE=0;        // PLLPRE (N2) 0=/2
PLLFBD=41;                  // pll multiplier (M) = +2
CLKDIVbits.PLLPOST=0;       // PLLPOST (N1) 0=/2
//OSCCON=0x11A0;
//OSCTUN = 0;
while(!OSCCONbits.LOCK);    // wait for PLL ready
Below is the LED blink test code.
dsPIC33FJ128GP802_LED_OK.fcfx
LED BLINK OK - INTERNAL OSCILLATOR
(8.75 KiB) Downloaded 211 times

Post Reply