




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
;*;*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 ; 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 ;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 *;*;*;*a. Here is a example for HI-TECH PICC *;*/*#include #include /*/*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 /*/*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 /*/*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 #pra
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论