Hot!dsPIC33fj256mc710a OSC settings for 40MHz operation on 16/32 development board

Author
66pvoarvp
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2016/12/05 18:29:36
  • Location: 0
  • Status: offline
2018/07/03 04:36:01 (permalink)
0

dsPIC33fj256mc710a OSC settings for 40MHz operation on 16/32 development board

Hi,
we are experimenting with 16/32 development board with dsPIC33FJ256MC710A PIM.
we wrote small programs to work with leds, switches etc., and tested them.
The following fuse settings are used:
 
// FBS
#pragma config BWRP = WRPROTECT_OFF // Boot Segment Write Protect (Boot Segment may be written)
#pragma config BSS = NO_FLASH // Boot Segment Program Flash Code Protection (No Boot program Flash segment)
#pragma config RBS = NO_RAM // Boot Segment RAM Protection (No Boot RAM)

// FSS
#pragma config SWRP = WRPROTECT_OFF // Secure Segment Program Write Protect (Secure Segment may be written)
#pragma config SSS = NO_FLASH // Secure Segment Program Flash Code Protection (No Secure Segment)
#pragma config RSS = NO_RAM // Secure Segment Data RAM Protection (No Secure RAM)

// FGS
#pragma config GWRP = OFF // General Code Segment Write Protect (User program memory is not write-protected)
#pragma config GSS = OFF // General Segment Code Protection (User program memory is not code-protected)

// FOSCSEL
#pragma config FNOSC = FRC // Oscillator Mode (Primary Oscillator (XT, HS, EC))
#pragma config IESO = OFF // Two-speed Oscillator Start-Up Enable (Start up with user-selected oscillator)

// FOSC
#pragma config POSCMD = NONE // Primary Oscillator Source (XT Oscillator Mode)
#pragma config OSCIOFNC = ON // OSC2 Pin Function (OSC2 pin has clock out function)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor (Both Clock Switching and Fail-Safe Clock Monitor are disabled)

// FWDT
#pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler (1:32,768)
#pragma config WDTPRE = PR128 // WDT Prescaler (1:128)
#pragma config PLLKEN = ON // PLL Lock Enable bit (Clock switch to PLL source will wait until the PLL lock signal is valid.)
#pragma config WINDIS = OFF // Watchdog Timer Window (Watchdog Timer in Non-Window mode)
#pragma config FWDTEN = ON // Watchdog Timer Enable (Watchdog timer always enabled)

// FPOR
#pragma config FPWRT = PWR128 // POR Timer Value (128ms)
#pragma config LPOL = OFF // Low-side PWM Output Polarity (Active Low)
#pragma config HPOL = OFF // Motor Control PWM High Side Polarity bit (PWM module high side output pins have active-low output polarity)
#pragma config PWMPIN = ON // Motor Control PWM Module Pin Mode bit (PWM module pins controlled by PORT register at device Reset)

// FICD
#pragma config ICS = PGD1 // Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
#pragma config JTAGEN = OFF // JTAG Port Enable (JTAG is Disabled)

Following code is used to set clock to 40MHz.
   CLKDIVbits.PLLPRE=0; // PLLPRE (N2) 0=/2
    PLLFBD=38; // pll multiplier (M) = +2
    CLKDIVbits.PLLPOST=0; // PLLPOST (N1) 0=/2
    while(!OSCCONbits.LOCK); // wait for PLL ready

following code is for flashing led:
 LED_Enable ( led1 );

    while(1){
    LED_Toggle( led1);
       __delay_ms(10);
    LED_Toggle ( led1);
     __delay_ms(10);
}

we are supposed to get 50Hz squarewave.
 
the program works when
while(!OSCCONbits.LOCK); // wait for PLL ready

is commented and is giving squarewave with 20Hz frequency.
 
When above line is uncommented, it is not executing, no response/flashing from the board.
 
Are these fuse settings right?
or any mistake in OSC init code?
 
any hint or help is requested.
 
Thanks,
 
 
 
#1

2 Replies Related Threads

    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re: dsPIC33fj256mc710a OSC settings for 40MHz operation on 16/32 development board 2018/07/03 04:39:57 (permalink)
    0
    You may try
    #pragma config FNOSC = FRCPLL           // Oscillator Source Selection (Fast RC Oscillator with divide-by-N with PLL module (FRCPLL))
    #pragma config IESO = ON                // Two-speed Oscillator Start-up Enable bit (Start up device with FRC, then switch to user-selected oscillator source)


    The above happened to me too in the past, and I was never sure-sure what was the exact reason: in theory, exceeding PLL requirements, but your 7.37/40 seems to be ok at a glance...

    GENOVA :D :D ! GODO
    #2
    66pvoarvp
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2016/12/05 18:29:36
    • Location: 0
    • Status: offline
    Re: dsPIC33fj256mc710a OSC settings for 40MHz operation on 16/32 development board 2018/08/15 21:28:33 (permalink)
    4 (1)
    Thanks DarioG,
     
    It worked.
    #3
    Jump to:
    © 2018 APG vNext Commercial Version 4.5