找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 757|回复: 0
打印 上一主题 下一主题
收起左侧

PIC系列单片机配置字配置方法

[复制链接]
跳转到指定楼层
楼主
以PIC18F4580单片机为例

PIC18F4580配置字
1、首先查看芯片手册,找到配置字描述部分


2、Search for the header file for your device(pic18f458.h) in your compiler library directory. Then see what the names are for the bit masking(e.g. WDTDIS)…(根据实际硬件设计配置)
__CONFIG(1, OSC_HS); /* HS oscillator */__CONFIG(2, (BORV_3 & BOREN_BOHW & PWRT_OFF & WDT_OFF & WDTPS_32768)); /* VBOR set to 2.1V,                      Brown-out Reset enabled in hardware only (SBOREN is disabled),                      PWRT disabled,                      Watchdog Timer Postscale, 1:32,768                      WDT disabled (control is placed on the SWDTEN bit) */__CONFIG(3, (MCLRE_OFF & LPT1OSC_OFF & PBADEN_OFF)); /* MCLR pin enabled; RE3 input pin disabled,                      Timer1 configured for higher power operation,                      PORTB<4:0> pins are configured as digital I/O on Reset */__CONFIG(4, (DEBUG_OFF & BBSIZ_1024 & LVP_OFF & STVREN_ON)); /* Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins,                         Instruction set extension and Indexed Addressing mode disabled (Legacy mode),                         1K words (2 Kbytes) boot block,                         Single-Supply ICSP disabled,                         Stack full/underflow will cause Reset */

3、编译之后,使用PICKit3升级固件,ImportHex时,可以看到配置字


4、正确配置PIC单片机配置字之后,可以解决程序无法启动问题(一般是因为时钟源没有配置导致芯片没有起振)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表