• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 請問組態設定要怎麼寫?
#10
資深會員
資深會員


查看用戶資訊
收到了
謝囉
建議可以把這一篇config.txt放到討論區的精華區裡
或是範例程式裡
這樣大家要找比較方便
我在一般的書中都沒看到該如何寫組態設定
規格書中有寫各位元的代表意義
但沒有說明有這種寫法...

發表於: 2005/4/13 12:07
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問組態設定要怎麼寫?
#9
版主
版主


查看用戶資訊
Jubel,

已經用 e-mail 傳過去了,內容包含 Configuration setting & Internal EEPROM.

發表於: 2005/4/13 11:15
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問組態設定要怎麼寫?
#8
資深會員
資深會員


查看用戶資訊
版主
請問你放了嗎?
我都找不到 ~_~"

發表於: 2005/4/13 9:05
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問組態設定要怎麼寫?
#7
版主
版主


查看用戶資訊
下午會把它放在右邊的範例程式裡。

發表於: 2005/4/11 9:47
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問組態設定要怎麼寫?
#6
資深會員
資深會員


查看用戶資訊
版主
是否可以把這個檔案寄給我?
我的瀏覽器不是火狐狸
複製貼上會出問題
我的郵件地址是 yagyu.jubel@msa.hinet.net
謝謝~

發表於: 2005/4/11 9:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問組態設定要怎麼寫?
#5
版主
版主


查看用戶資訊
你要的 Configuration setting 方式都在這裡 :

;************************************************************************************
;*
CONFIG Setting for PIC16/18                                                        *
;*
This text is mainly on the method for the setting of configuration bits with both assembler&C.    *
;************************************************************************************

--------------  
MPASM for PIC16Fxxx   ----------------------------------------------------

;*******************************************************************************************
;*
1.To set CONFIG with assembler                                                                 *
;*
With the source code written in assembler the configuration bits can been set by micro __CONFIG  *
;*
The micro __CONFIG  is after with the include file.                                                  *
;*******************************************************************************************

;*******************************************************************************************
;*
Example 1,  CONFIG set for 16F877A                                                             *
;*******************************************************************************************
    list    
p=16f877A    ; list directive to define processor
    
#include    <p16f877A.inc>    ; processor specific variable definitions
;************************************************************************
;*
Configuration bits                                                        *
;*
The __CONFIG directive defines configuration data within the .ASM file.        *
;* 
The labels following the directive are defined in the P16F877A.INC file.        *
;*
The PIC16F877A Data Sheet explains the functions of the configuration bits.    *
;************************************************************************
__CONFIG _CP_OFF _WDT_OFF _BODEN_OFF _PWRTE_ON _RC_OSC _WRT_OFF _LVP_ON _CPD_OFF

variable definitions
;your code
;;
END    ˙end of program
;**********************************************************************************

-------------------   
MPASM for PIC18Fxxxx   -----------------------------------

;**************************************************************************************
;*
Example 2CONFIG set for 18F452. As the configuration bits is more complex than 16F877,     *
;*
it maps to more bytes in program memory instead of  one word.                               *
;**************************************************************************************
    LIST 
P=18F452            ;directive to define processor
    
#include <P18F452.INC>    ;processor specific variable definitions
;****************************************************************************
;*
Configuration bits                                                            *
;*
The __CONFIG directive defines configuration data within the .ASM file.            *
;* 
The labels following the directive are defined in the P18F452.INC file.            *
; *
The PIC18FXX2 Data Sheet explains the functions of the configuration bits.        *
;*****************************************************************************

    
__CONFIG    _CONFIG1H_OSCS_OFF_1H _HS_OSC_1H
    __CONFIG    _CONFIG2L
_BOR_OFF_2L _PWRT_OFF_2L
    __CONFIG    _CONFIG2H
_WDT_OFF_2H
    __CONFIG    _CONFIG3H
_CCP2MX_OFF_3H
    __CONFIG    _CONFIG4L
_STVR_OFF_4L _LVP_OFF_4L _DEBUG_OFF_4L
    __CONFIG    _CONFIG5L
_CP0_OFF_5L _CP1_OFF_5L _CP2_OFF_5L _CP3_OFF_5L 
    __CONFIG    _CONFIG5H
_CPB_OFF_5H _CPD_OFF_5H
    __CONFIG    _CONFIG6L
_WRT0_OFF_6L _WRT1_OFF_6L _WRT2_OFF_6L _WRT3_OFF_6L 
    __CONFIG    _CONFIG6H
_WRTC_OFF_6H _WRTB_OFF_6H _WRTD_OFF_6H
    __CONFIG    _CONFIG7L
_EBTR0_OFF_7L _EBTR1_OFF_7L _EBTR2_OFF_7L _EBTR3_OFF_7L
    __CONFIG    _CONFIG7H
_EBTRB_OFF_7H

;******************************************************************************
;
Variable definitions
;your code
;;
    
END;    end of program
;******************************************************************************

-------------------------  
Hi-Tech PICC  (16Fxxxx) -------------------------------------

;********************************************************    
;*
2.To set CONFIG with C language                            *
;********************************************************

;************************************************************************************
;*
aHere is a example for  HI-TECH PICC                                                 *
;************************************************************************************
//**************************************************************************************
#include <pic.h>
#include <pic168xa.h>

//***************************************************************************************
//*The declaration of __CONFIG() is in pic.h                    *
//*The __CONFIG(x) directive defines configuration data within is in pic168xa.h        *
//***************************************************************************************
__CONFIG(XT&WDTDIS&PWRTEN&BORDIS&LVPDIS&DUNPROT&DEBUGDIS&UNPROTECT);
void main(void)
{
//your code
}
//***************************************************************************************

//****************************************************************************
//*In pic.h the definition of __CONFIG(x) is as follows:                            *
/*#define    __CONFIG(x)    asm("tpsect config,class=CONFIG,delta=2");        *
            asm("tdw "___mkstr(x))                                    */
//* pic168xa.h defines all the configuation bit values                        *
//*#define CONFIG_ADDR    0x2007    


--------------------- Hi-Tech PICC18   ------------------------------------------------

****************************************************************************************
//*b.In HI-TECH C18 , use macro __CONFIG(n,x)
//***************************************************************************************
    #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
}
//*************************************************************************

//************************************************************************
//*In pic18.h the definition of __CONFIG(n,x) is as follows                    *    
//*#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))                                        *
//* pic18fxx2.h defines the configuration bit values,                              *
//************************************************************************

--------------------    MPLAB C18   ----------------------------------------

;*******************************************************************************
;*
3.For MPLAB C18 V2.40 or higher, use #pragma config directive                       *
;*for example                                                                     *    
//******************************************************************************
    #include <p18f452.h>
//*******************************************************************************
//*Configuration settings may be specified with multiple #pragma config directives.          *
//*MPLAB C18 verifies that the configuration settings specified are valid for the processor*
//*for which it is compiling                                                                                *            
//*The labels following the directive "pragma config" are defined in the P18F452.h file.    *
//*******************************************************************************
    #pragma config    OSC=HS
    #pragma config     PWRT=ON
    #pragma config     BOR=OFF, BORV=42
    #pragma config     WDT=OFF
    #pragma config      CCP2MUX=ON
    #pragma config      STVR=OFF, LVP=OFF, DEBUG=OFF
    #pragma config      CPD=OFF
    
void main(void)
{
//your code
}
//********************************************************************************

發表於: 2005/4/9 10:28
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問組態設定要怎麼寫?
#4
高級會員
高級會員


查看用戶資訊
__CONFIG _CP_OFF & _WDT_ON & _BODEN_ON
& _PWRTE_ON & _RC_OSC

利用__CONFIG來定義 , 而"&"來連結不同的設定
下面的定義字可以在INC檔中找到 , 每一個PIC都有些許的差別

;==================================;
; Configuration Bits
;==================================;
_BODEN_ON EQU H'3FFF'
_BODEN_OFF EQU H'3FBF'
_CP_ALL EQU H'00CF'
_CP_75 EQU H'15DF'
_CP_50 EQU H'2AEF'
_CP_OFF EQU H'3FFF'
_PWRTE_OFF EQU H'3FFF'
_PWRTE_ON EQU H'3FF7'
_WDT_ON EQU H'3FFF'
_WDT_OFF EQU H'3FFB'
_LP_OSC EQU H'3FFC'
_XT_OSC EQU H'3FFD'
_HS_OSC EQU H'3FFE'
_RC_OSC EQU H'3FFF'

發表於: 2005/4/8 9:18
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問組態設定要怎麼寫?
#3
資深會員
資深會員


查看用戶資訊
板主辛苦了
這麼晚了還來回答問題

剛剛忘了說明
我是用組合語言的
所以那些好像不適合^^"

嗯...程式編譯完成後
如果程式碼裡有寫到組態設定就以程式為主
那還是直接寫到程式裡比較保險...

發表於: 2005/4/8 0:47
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問組態設定要怎麼寫?
#2
管理員
管理員


查看用戶資訊
請問是 C18 嗎 ? 若是的話就看看下面的說明啦 :

MPLAB C18 V2.40 and newer

把下面的選項加在程式的開頭 . 注意 !! 您可能有更多選項要指定. 詳細的選項說明請下在以下的 C18 Addendum : ( DS51537A)

http://ww1.microchip.com/downloads/en ... onfig_Settengs_51537a.pdf

#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF

MPLAB C18 V2.40 以前版本 :
將以下片段加入程式中. 當然, 各暫存器的值要依照需要而修改
#pragma romdata CONFIG
const rom unsigned char CONFIG1L=0xff ; // Don't care byte
const rom unsigned char CONFIG1H=0b00100010 ; // Disable OSC switch , XXXXX010 = HS
const rom unsigned char CONFIG2L=0b00000001 ; // Disable PWRT , Disable BOR
const rom unsigned char CONFIG2H=0b00000000 ; // Disable WDT timer
const rom unsigned char CONFIG3L=0xff ; // Don't care byte
const rom unsigned char CONFIG3H=0b00000000 ; // XXXXXXX0 = CCP2 --> RB3
const rom unsigned char CONFIG4L=0b00000001 ; // 0XXXXXXX Backgroung Debug Enable
const rom unsigned char CONFIG4H=0xff ; // Don't care byte
const rom unsigned char CONFIG5L=0b00001111 ; // Not PROG code protected
const rom unsigned char CONFIG5H=0b11000000 ; // Not EEPROM code protected
const rom unsigned char CONFIG6L=0b00001111 ;
const rom unsigned char CONFIG6H=0b11100000 ;
const rom unsigned char CONFIG7L=0b00001111 ;
const rom unsigned char CONFIG7H=0b01000000 ;
#pragma romdata

最後 , 程式中宣告的項目會在每次 Compiler 成功後重新載入 Configuration Bytes. 所以他是比手動設定更優先的.

Best Regards,


發表於: 2005/4/8 0:42
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問組態設定要怎麼寫?
#1
資深會員
資深會員


查看用戶資訊
我平常都是用ICD2燒錄程式
改組態都到MPLAB的選單裡去改
我想把程式碼鎖住讓人無法讀出
請問在程式中要如何直接用寫的設定組態呢?

因為我怕要是忘了改MPLAB裡的設定
到時候程式碼都沒鎖就會被讀出了
直接寫在程式裡就不怕忘了改設定了...

另外還有一個問題
我把組態設定寫到程式裡後
mPLAB裡的設定跟程式裡寫的設定若不同
到時燒錄是依據哪個為主?

發表於: 2005/4/8 0:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------