欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: picc18應(yīng)用筆記:在源程序中設(shè)置配置位 [打印本頁]

作者: 葛靖青    時間: 2010-11-2 16:07
標題: picc18應(yīng)用筆記:在源程序中設(shè)置配置位
對于HI-TECH C18 , 配置字的設(shè)定通過宏 __CONFIG(n,x)來實現(xiàn).
宏__CONFIG(n,x)的聲明在文件pic18.h中,各位元的聲明在對應(yīng)芯片型號的頭文件中.18F452的例程如下:

//***************************************************************************************
        #include <pic18.h>
//***************************************************************************************
//*The declaration of __CONFIG(n,x) is in pic18.h                                        *
//*The __CONFIG(n,x) directive defines configuration data within is in pic18fxx2.h                *
//***************************************************************************************
        __CONFIG(1,RC) ;
        __CONFIG(2,PWRTDIS & WDTPS1 & WDTEN ) ;
        __CONFIG(4,STVRDIS) ;
        
        void main(void)
{
//your code
}
//*************************************************************************

在pic18.h中,__CONFIG(n,x)的聲明如下         
#define        __CONFIG(n, x)        asm("\tpsect config,class=CONFIG");\
                        asm("global config_word" ___mkstr(n)); \
                        asm("config_word" ___mkstr(n)":"); \
                        asm("\torg ("___mkstr(n)"-1)*2"); \
                        asm("\tdw "___mkstr(x))
部分在pic18.h中的聲明大體如下,具體請參考對應(yīng)的頭文件。
// Configuration bit values
// Config. Register 1
#define OSCSEN                0xDFFF                // enable oscillator system clock
#define OSCSDIS                0xFFFF
// oscilator types
#define RCRA6                0xFFFF                // RC w/OSC2 config as RA6
#define HSPLL                0xFEFF                // HS w/PLL Enabled, Clk Freq = 4xFreq Osc.
#define ECRA6                0xFDFF                // EC w/OSC2 config. as RA6
#define ECDB4                0xFCFF                // EC w/OSC2 as divide by 4 clock output
#define RC                0xFBFF
#define HS                0xFAFF
#define XT                0xF9FF                 
#define LP                        0xF8FF

// Config. Register 2
// Brown Out reset
#define        BOREN                0xFFFF                // Brown-out reset enable

n代表 Config. Register n, 例如__CONFIG(1,x); 1 代表Config. Register 1, X可為OSCSEN,RC等。




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1