sistem frekansının ayarlanması

Başlatan SK, 13 Mart 2015, 21:02:59

SK

selamlar
32MX795F512L için sistem frekansını 80 MHz e ayarladım ancak bu frekansı bozan bişeyler var. delayms(500) dediğimde yaklaşık 2-1.5 sn bekliyor. osilator ayarları doğru ancak sistem doğru çalışmıyor. aslında çalışıyor bi sıkıntı yok ancak sistem frekansını denemek için delayms(500) dediğimde bi sorun olduğunu farkettim. bu sorunun kaynağı ne olabilir? osilator frekansı ayarlaması ve diyagramı aşağıdaki şekilde.

#pragma config POSCMOD = HS             //hs osilator
#pragma config FNOSC = PRIPLL           //primary osilator with PLL
#pragma config FSOSCEN = ON             //Secondary Oscillator Enable bit
#pragma config FPLLIDIV = DIV_2
#pragma config FPLLMUL = MUL_20
#pragma config FPLLODIV = DIV_1
#pragma config OSCIOFNC = OFF            //CLKO Enable Configuration bit



mehmet

Böyle bir şey işinize yarayabilir...
Derlenirken uyarılar çıkıyor. Onları da siz halledersiniz...

http://www.microchip.com/forums/m760977.aspx

#ifdef __XC32
    #include <xc.h>
#endif
#include <plib.h>
#include <stdint.h>
#include <stdbool.h>
#include <p32xxxx.h>

// DEVCFG3
// USERID = No Setting
#pragma config FSRSSEL = PRIORITY_7     // SRS Select (SRS Priority 7)
#pragma config FMIIEN = ON              // Ethernet RMII/MII Enable (MII Enabled)
#pragma config FETHIO = ON              // Ethernet I/O Pin Select (Default Ethernet I/O)
#pragma config FCANIO = ON              // CAN I/O Pin Select (Default CAN I/O)
#pragma config FUSBIDIO = ON            // USB USID Selection (Controlled by the USB Module)
#pragma config FVBUSONIO = ON           // USB VBUS ON Selection (Controlled by USB Module)

// DEVCFG2
#pragma config FPLLIDIV = DIV_12        // PLL Input Divider (12x Divider)
#pragma config FPLLMUL = MUL_24         // PLL Multiplier (24x Multiplier)
#pragma config UPLLIDIV = DIV_12        // USB PLL Input Divider (12x Divider)
#pragma config UPLLEN = OFF             // USB PLL Enable (Disabled and Bypassed)
#pragma config FPLLODIV = DIV_256       // System PLL Output Clock Divider (PLL Divide by 256)

// DEVCFG1
#pragma config FNOSC = FRCDIV           // Oscillator Selection Bits (Fast RC Osc w/Div-by-N (FRCDIV))
#pragma config FSOSCEN = ON             // Secondary Oscillator Enable (Enabled)
#pragma config IESO = ON                // Internal/External Switch Over (Enabled)
#pragma config POSCMOD = OFF            // Primary Oscillator Configuration (Primary osc disabled)
#pragma config OSCIOFNC = OFF           // CLKO Output Signal Active on the OSCO Pin (Disabled)
#pragma config FPBDIV = DIV_8           // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/8)
#pragma config FCKSM = CSDCMD           // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
#pragma config WDTPS = PS1048576        // Watchdog Timer Postscaler (1:1048576)
#pragma config FWDTEN = ON              // Watchdog Timer Enable (WDT Enabled)

// DEVCFG0
#pragma config DEBUG = OFF              // Background Debugger Enable (Debugger is disabled)
#pragma config ICESEL = ICS_PGx2        // ICE/ICD Comm Channel Select (ICE EMUC2/EMUD2 pins shared with PGC2/PGD2)
#pragma config PWP = OFF                // Program Flash Write Protect (Disable)
#pragma config BWP = OFF                // Boot Flash Write Protect bit (Protection Disabled)
#pragma config CP = OFF                 // Code Protect (Protection Disabled)




/////////////////////////////////////////////////////////
#define    LED_R                           LATDbits.LATD1
#define    LED_Y                            LATDbits.LATD2
#define    LED_G                           LATDbits.LATD3
#define    R_tri                              TRISDbits.TRISD1
#define    Y_tri                              TRISDbits.TRISD2
#define    G_tri                              TRISDbits.TRISD3

#define FOSC    80000000 //80Mhz
#define GetSystemClock()      (FOSC)

//////////////////////////////////////////////////////////
 void DelayMs(WORD delay)
 {
     unsigned int int_status;
     while( delay-- )
     {
         int_status = INTDisableInterrupts();
         OpenCoreTimer(GetSystemClock() / 2000);
         INTRestoreInterrupts(int_status);
         mCTClearIntFlag();
         while( !mCTGetIntFlag() );
     }
     mCTClearIntFlag();
 }
//////////////////////////////////////////////
void main(void)
{
    while(true)
    {
        LED_R=1;
        DelayMs(100);
        LED_R=0;
        LED_Y=1;
        DelayMs(100);
        LED_Y=0;
        LED_G=1;
        DelayMs(100);
        LED_G=0;
        /*loop for ever*/
    }
}
Olan olmuştur,
olacak olan da olmuştur.
Olacak bir şey yoktur.
---------------------------------------------
http://www.mehmetbilgi.net.tr