|
Tài trợ cho PIC Vietnam |
PIC32 - Bộ điều khiển tín hiệu số 32-bit Microchip công bố sản phẩm vi xử lý 32-bit ngày 06/11/2007 |
|
Ðiều Chỉnh | Xếp Bài |
17-01-2008, 12:42 PM | #1 |
PIC Bang chủ
|
Lôi System.h ra coi chơi nhỉ :)
Code:
/******************************************************************** * FileName: System.h * Dependencies: * Processor: PIC32 * Hardware: N/A * Assembler: N/A * Linker: N/A * Company: Microchip Technology, Inc. ********************************************************************/ #ifndef _SYSTEM_HEADER_FILE #define _SYSTEM_HEADER_FILE #include <p32xxxx.h> #include <peripheral/int.h> #include <peripheral/pcache.h> #include <peripheral/osc.h> #include <peripheral/dma.h> #include <peripheral/bmx.h> #include <peripheral/lock.h> #define FLASH_ACCESS_TIME_HZ 20000000 #define PB_BUS_ACCESS_TIME_HZ 50000000 Code:
/********************************************************************* * Function: void SYSTEMConfigPB(unsigned int sys_clock) * * PreCondition: None * * Input: sys_clock - system clock in Hz * * Output: the PB divider value * * Side Effects: Sets the PB divider to the optimum value ********************************************************************/ extern inline unsigned int __attribute__((always_inline)) SYSTEMConfigPB(unsigned int sys_clock) { unsigned int dma_status; unsigned int int_status; unsigned int pb_clock; pb_clock = sys_clock; mSYSTEMUnlock(int_status, dma_status); // set the PB Div if(sys_clock > PB_BUS_ACCESS_TIME_HZ) { mOSCSetPBDIV(OSC_PB_DIV_2); pb_clock >>= 1; } else { mOSCSetPBDIV(OSC_PB_DIV_1); } mSYSTEMLock(int_status, dma_status); return pb_clock; } Code:
/********************************************************************* * Function: void SYSTEMConfigWaitStatesAndPB(unsigned int sys_clock) * * PreCondition: None * * Input: sys_clock - system clock in Hz * * Output: None * * Side Effects: Sets the PB and Flash Wait states ********************************************************************/ extern inline unsigned int __attribute__((always_inline)) SYSTEMConfigWaitStatesAndPB(unsigned int sys_clock) { #ifdef _PCACHE unsigned int wait_states; #endif unsigned int pb_clock; unsigned int int_status; pb_clock = SYSTEMConfigPB(sys_clock); // set the flash wait states based on 1 wait state // for every 25 MHz #ifdef _PCACHE wait_states = 0; while(sys_clock >= FLASH_ACCESS_TIME_HZ) { wait_states++; sys_clock -= FLASH_ACCESS_TIME_HZ; } int_status=INTDisableInterrupts(); mCheConfigure(wait_states); INTRestoreInterrupts(int_status); #endif return pb_clock; } Code:
/********************************************************************* * Function: void SYSTEMConfigPerformance(unsigned int sys_clock, unsigned int flag) * * PreCondition: None * * Input: sys_clock - system clock in Hz * * Output: None * * Side Effects: Sets the PB and Flash Wait states ********************************************************************/ extern inline unsigned int __attribute__((always_inline)) SYSTEMConfigPerformance(unsigned int sys_clock) { // set up the wait states unsigned int pb_clk; #ifdef _PCACHE unsigned int cache_status; #endif unsigned int int_status; pb_clk = SYSTEMConfigWaitStatesAndPB(sys_clock); int_status=INTDisableInterrupts(); mBMXDisableDRMWaitState(); #ifdef _PCACHE cache_status = mCheGetCon(); cache_status |= CHE_CONF_PF_ALL; mCheConfigure(cache_status); CheKseg0CacheOn(); #endif INTRestoreInterrupts(int_status); return pb_clk; } #endif Chúc vui
__________________
Công ty TNHH Thương mại và Giao nhận R&P store.hn@rpc.vn - store.hcm@rpc.vn Học PIC như thế nào? |
17-01-2008, 12:46 PM | #2 |
Đệ tử 4 túi
Tham gia ngày: May 2007
Bài gửi: 69
: |
anh có thể phân tích đôi chút không anh
|
|
|