In a demo software from Olimex for the PIC32-MAXI-WEB the configuration words for the osc are set as follows:

/** CONFIGURATION **************************************************/

#pragma config FNOSC    = PRIPLL        // Oscillator Selection
#pragma config FPLLMUL  = MUL_20        // PLL Multiplier
#pragma config FPLLIDIV = DIV_2         // PLL Input Divider
#pragma config FPLLODIV = DIV_1         // PLL Output Divider
#pragma config FPBDIV   = DIV_1        // Peripheral Clock divisor

There are the following macros for getting the clock speeds;

#define SYS_CLOCK             (80000000ul)
#define GetSystemClock()      (SYS_CLOCK)
#define GetPeripheralClock()  (SYS_CLOCK/2)
#define GetInstructionClock() (SYS_CLOCK)

The main clock should be 8MHz / 2 * 20 / 1 = 80

Is the PeripheralClock = SYS_CLOCK/2 a bug/typo, as the FPBDIV is set to 1. I tried to look for it in the datasheet. Is there indeed a bug, or is there some kind of internal division by 2 that is always active or activated by some other condition/register. (Like how the instruction clock was FOsc/4 on some devices)

  • \$\begingroup\$ What's the definition of DIV_1? \$\endgroup\$ Sep 17, 2013 at 15:19
  • \$\begingroup\$ @Madmanguruman I think it is somekind of a compiler (xc32) constant. A quick search turns out: CVALUE:00000000:DIV_1:1x Divider in xc32/v1.21/pic32mx/lib/proc/<device>/configuration.data \$\endgroup\$
    – varesa
    Sep 17, 2013 at 15:34

2 Answers 2


It's a bug. The peripheral clock should be equal to the system clock if you set FPBDIV = DIV_1.

So it should be:

#define GetPeripheralClock()  (SYS_CLOCK)

Yes, a better way of defining peripheral clock would be:

#define GetSystemClock()            (80000000ul)
#define GetInstructionClock()       (GetSystemClock())
#define GetPeripheralClock()        (GetSystemClock()/(1<<OSCCONbits.PBDIV))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.