打印
[PIC®/AVR®/dsPIC®产品]

XC8嵌入式编程手册,含有大量实例

[复制链接]
560|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
gejigeji521|  楼主 | 2024-3-11 22:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
MPLAB XC8 C Compiler UG EE DS50002400C .pdf (792 KB)
例如配置字
// CONFIG1
#pragma config FOSC = ECH // External Clock, 4-20 MHz
#pragma config WDTE = OFF // Watchdog Timer (WDT) disabled
#pragma config PWRTE = OFF // Power-up Timer disabled
#pragma config MCLRE = ON // MCLR/VPP pin function is MCLR
#pragma config CP = OFF // Flash Memory Code Protection off
#pragma config BOREN = ON // Brown-out Reset enabled
#pragma config CLKOUTEN = OFF // Clock Out disabled.
#pragma config IESO = ON // Internal/External Switchover on
#pragma config FCMEN = ON // Fail-Safe Clock Monitor enabled
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protect off
#pragma config PPS1WAY = ON // PPS one-way control enabled
#pragma config ZCDDIS = ON // Zero-cross detect disabled
#pragma config PLLEN = OFF // Phase Lock Loop disable
#pragma config STVREN = ON // Stack Over/Underflow Reset enabled
#pragma config BORV = LO // Brown-out Reset low trip point
#pragma config LPBOR = OFF // Low-Power Brown Out Reset disabled
#pragma config LVP = OFF // Low-Voltage Programming disabled


使用特权

评论回复
沙发
gejigeji521|  楼主 | 2024-3-11 22:55 | 只看该作者
#include <xc.h> 
#include <stdint.h>
void main(void) {
uint8_t portValue = 0x05;
ANSELB = 0x0; // set to digital I/O (not analog)
TRISB = 0x0; // set all port bits to be output
LATB = portValue; // write to port latch - RB[0:3] = LED[4:7]
// Port D access
ANSELD = 0x0; // set to digital I/O (not analog)
TRISD = 0x0; // set all port bits to be output
LATD = portValue; // write to port latch - RD[0:3] = LED[0:3]
}


使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

177

主题

2229

帖子

8

粉丝