[PIC®/AVR®/dsPIC®产品] XC8嵌入式编程手册,含有大量实例

[复制链接]
797|1
 楼主| gejigeji521 发表于 2024-3-11 22:55 | 显示全部楼层 |阅读模式

例如配置字
  1. // CONFIG1
  2. #pragma config FOSC = ECH // External Clock, 4-20 MHz
  3. #pragma config WDTE = OFF // Watchdog Timer (WDT) disabled
  4. #pragma config PWRTE = OFF // Power-up Timer disabled
  5. #pragma config MCLRE = ON // MCLR/VPP pin function is MCLR
  6. #pragma config CP = OFF // Flash Memory Code Protection off
  7. #pragma config BOREN = ON // Brown-out Reset enabled
  8. #pragma config CLKOUTEN = OFF // Clock Out disabled.
  9. #pragma config IESO = ON // Internal/External Switchover on
  10. #pragma config FCMEN = ON // Fail-Safe Clock Monitor enabled
  11. // CONFIG2
  12. #pragma config WRT = OFF // Flash Memory Self-Write Protect off
  13. #pragma config PPS1WAY = ON // PPS one-way control enabled
  14. #pragma config ZCDDIS = ON // Zero-cross detect disabled
  15. #pragma config PLLEN = OFF // Phase Lock Loop disable
  16. #pragma config STVREN = ON // Stack Over/Underflow Reset enabled
  17. #pragma config BORV = LO // Brown-out Reset low trip point
  18. #pragma config LPBOR = OFF // Low-Power Brown Out Reset disabled
  19. #pragma config LVP = OFF // Low-Voltage Programming disabled


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
 楼主| gejigeji521 发表于 2024-3-11 22:55 | 显示全部楼层
  1. #include <xc.h>
  2. #include <stdint.h>
  3. void main(void) {
  4. uint8_t portValue = 0x05;
  5. ANSELB = 0x0; // set to digital I/O (not analog)
  6. TRISB = 0x0; // set all port bits to be output
  7. LATB = portValue; // write to port latch - RB[0:3] = LED[4:7]
  8. // Port D access
  9. ANSELD = 0x0; // set to digital I/O (not analog)
  10. TRISD = 0x0; // set all port bits to be output
  11. LATD = portValue; // write to port latch - RD[0:3] = LED[0:3]
  12. }


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

本版积分规则

196

主题

2465

帖子

8

粉丝
快速回复 在线客服 返回列表 返回顶部