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


Browsing this Thread:   1 Anonymous Users






Re: 關於燒錄與Configuration bit的問題
#3
版主
版主


查看用戶資訊
Configuration 設定的範例 :
[code]
;************************************************************************************
;*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 2, CONFIG 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
;******************************************************************************

;**************************** PIC18Fxxxx 新版使用方式 *********************************
; *
; Files required: P18F4520.INC *
; *
;******************************************************************************

LIST P=18F4520 ;directive to define processor
#include <P18F4520.INC> ;processor specific variable definitions

;******************************************************************************
;Configuration bits
;Microchip has changed the format for defining the configuration bits, please
;see the .inc file for futher details on notation. Below are a few examples.



; Oscillator Selection:
CONFIG OSC = LP ;LP
******************************************************

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

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

;************************************************************************************
;*a. Here 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
}
//********************************************************************************
{/code]

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


Re: 關於燒錄與Configuration bit的問題
#2
資深會員
資深會員


查看用戶資訊

發表於: 2007/8/8 9:08
木亟缶夬金戔
彳艮缶夬金戔
走召缶夬金戔
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


關於燒錄與Configuration bit的問題
#1
新會員
新會員


查看用戶資訊
想請教一個問題
就是我用ICD2燒錄PIC18F452的時候
按下燒錄鍵的時候
MPLAB IDE的Output/ICD2視窗
就會顯現目前的燒錄狀況
------------------------------------
MPLAB ICD 2 Ready
Programming Target...
...Erasing Part
...Programming Program Memory (0x0 - 0x76AF)
Verifying...
...Program Memory
...Verify Succeeded
...Programming succeeded
------------------------------------------
有的時候裡面會多顯示"Programing Configuration bit..."
有的時候卻不會
想請問為什麼呢?
要如何設定才能讓ICD2燒錄的時候
也順便燒Configuration bit 並顯現訊息
.
因為我燒時候
如果ICD2沒有顯示"Programing Configuration bit..."的話
燒好的PIC18F452執行時,會不斷地自己Reset
可是如果燒的時候
ICD2視窗有顯示"Programing Configuration bit..."的話
就不會發生PIC18F452執行時會不斷地自己Reset問題
想請教一下
這個問題應該如呵解決呢?
謝謝,感恩!

發表於: 2007/8/8 0:35
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... ]

教育訓練中心

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