2020-02-06 09:56发布
yklstudent 发表于 2013-6-14 23:10 config1 config2需要配置的
millwood0 发表于 2013-6-14 21:30 I do.
xiongh 发表于 2013-6-15 10:18 MPLAB X + PICC 挺好用。 #include "pic.h" #include
最多设置5个标签!
除了学习板上的18F4520我还没用过其它PIC单片机。装了XC8免费版后,才找到PIC16F1824.h头文件。发现照搬之前的时钟配置
config过来用不了。打开之前用的PIC.h和现在的PIC16F1824.h对比,差远了。。。。
时钟不知道怎么配置。在DEBUG状态LED是能亮了。拔了仿真,直接给电不会运行。
头文件的部分:
- // Register: OSCCON
- extern volatile unsigned char OSCCON @ 0x099;
- #ifndef _LIB_BUILD
- asm("OSCCON equ 099h");
- #endif
- // bitfield definitions
- typedef union {
- struct {
- unsigned SCS0 :1;
- unsigned SCS1 :1;
- unsigned :1;
- unsigned IRCF0 :1;
- unsigned IRCF1 :1;
- unsigned IRCF2 :1;
- unsigned IRCF3 :1;
- unsigned SPLLEN :1;
- };
- struct {
- unsigned SCS :2;
- unsigned :1;
- unsigned IRCF :4;
- };
- } OSCCONbits_t;
- extern volatile OSCCONbits_t OSCCONbits @ 0x099;
- // bitfield macros
- #define _OSCCON_SCS0_POSN 0x0
- #define _OSCCON_SCS0_POSITION 0x0
- #define _OSCCON_SCS0_SIZE 0x1
- #define _OSCCON_SCS0_LENGTH 0x1
- #define _OSCCON_SCS0_MASK 0x1
- #define _OSCCON_SCS1_POSN 0x1
- #define _OSCCON_SCS1_POSITION 0x1
- #define _OSCCON_SCS1_SIZE 0x1
- #define _OSCCON_SCS1_LENGTH 0x1
- #define _OSCCON_SCS1_MASK 0x2
- #define _OSCCON_IRCF0_POSN 0x3
- #define _OSCCON_IRCF0_POSITION 0x3
- #define _OSCCON_IRCF0_SIZE 0x1
- #define _OSCCON_IRCF0_LENGTH 0x1
- #define _OSCCON_IRCF0_MASK 0x8
- #define _OSCCON_IRCF1_POSN 0x4
- #define _OSCCON_IRCF1_POSITION 0x4
- #define _OSCCON_IRCF1_SIZE 0x1
- #define _OSCCON_IRCF1_LENGTH 0x1
- #define _OSCCON_IRCF1_MASK 0x10
- #define _OSCCON_IRCF2_POSN 0x5
- #define _OSCCON_IRCF2_POSITION 0x5
- #define _OSCCON_IRCF2_SIZE 0x1
- #define _OSCCON_IRCF2_LENGTH 0x1
- #define _OSCCON_IRCF2_MASK 0x20
- #define _OSCCON_IRCF3_POSN 0x6
- #define _OSCCON_IRCF3_POSITION 0x6
- #define _OSCCON_IRCF3_SIZE 0x1
- #define _OSCCON_IRCF3_LENGTH 0x1
- #define _OSCCON_IRCF3_MASK 0x40
- #define _OSCCON_SPLLEN_POSN 0x7
- #define _OSCCON_SPLLEN_POSITION 0x7
- #define _OSCCON_SPLLEN_SIZE 0x1
- #define _OSCCON_SPLLEN_LENGTH 0x1
- #define _OSCCON_SPLLEN_MASK 0x80
- #define _OSCCON_SCS_POSN 0x0
- #define _OSCCON_SCS_POSITION 0x0
- #define _OSCCON_SCS_SIZE 0x2
- #define _OSCCON_SCS_LENGTH 0x2
- #define _OSCCON_SCS_MASK 0x3
- #define _OSCCON_IRCF_POSN 0x3
- #define _OSCCON_IRCF_POSITION 0x3
- #define _OSCCON_IRCF_SIZE 0x4
- #define _OSCCON_IRCF_LENGTH 0x4
- #define _OSCCON_IRCF_MASK 0x78
- // Register: OSCSTAT
- extern volatile unsigned char OSCSTAT @ 0x09A;
- #ifndef _LIB_BUILD
- asm("OSCSTAT equ 09Ah");
- #endif
- // bitfield definitions
- typedef union {
- struct {
- unsigned HFIOFS :1;
- unsigned LFIOFR :1;
- unsigned MFIOFR :1;
- unsigned HFIOFL :1;
- unsigned HFIOFR :1;
- unsigned OSTS :1;
- unsigned PLLR :1;
- unsigned T1OSCR :1;
- };
- } OSCSTATbits_t;
- extern volatile OSCSTATbits_t OSCSTATbits @ 0x09A;
- // bitfield macros
- #define _OSCSTAT_HFIOFS_POSN 0x0
- #define _OSCSTAT_HFIOFS_POSITION 0x0
- #define _OSCSTAT_HFIOFS_SIZE 0x1
- #define _OSCSTAT_HFIOFS_LENGTH 0x1
- #define _OSCSTAT_HFIOFS_MASK 0x1
- #define _OSCSTAT_LFIOFR_POSN 0x1
- #define _OSCSTAT_LFIOFR_POSITION 0x1
- #define _OSCSTAT_LFIOFR_SIZE 0x1
- #define _OSCSTAT_LFIOFR_LENGTH 0x1
- #define _OSCSTAT_LFIOFR_MASK 0x2
- #define _OSCSTAT_MFIOFR_POSN 0x2
- #define _OSCSTAT_MFIOFR_POSITION 0x2
- #define _OSCSTAT_MFIOFR_SIZE 0x1
- #define _OSCSTAT_MFIOFR_LENGTH 0x1
- #define _OSCSTAT_MFIOFR_MASK 0x4
- #define _OSCSTAT_HFIOFL_POSN 0x3
- #define _OSCSTAT_HFIOFL_POSITION 0x3
- #define _OSCSTAT_HFIOFL_SIZE 0x1
- #define _OSCSTAT_HFIOFL_LENGTH 0x1
- #define _OSCSTAT_HFIOFL_MASK 0x8
- #define _OSCSTAT_HFIOFR_POSN 0x4
- #define _OSCSTAT_HFIOFR_POSITION 0x4
- #define _OSCSTAT_HFIOFR_SIZE 0x1
- #define _OSCSTAT_HFIOFR_LENGTH 0x1
- #define _OSCSTAT_HFIOFR_MASK 0x10
- #define _OSCSTAT_OSTS_POSN 0x5
- #define _OSCSTAT_OSTS_POSITION 0x5
- #define _OSCSTAT_OSTS_SIZE 0x1
- #define _OSCSTAT_OSTS_LENGTH 0x1
- #define _OSCSTAT_OSTS_MASK 0x20
- #define _OSCSTAT_PLLR_POSN 0x6
- #define _OSCSTAT_PLLR_POSITION 0x6
- #define _OSCSTAT_PLLR_SIZE 0x1
- #define _OSCSTAT_PLLR_LENGTH 0x1
- #define _OSCSTAT_PLLR_MASK 0x40
- #define _OSCSTAT_T1OSCR_POSN 0x7
- #define _OSCSTAT_T1OSCR_POSITION 0x7
- #define _OSCSTAT_T1OSCR_SIZE 0x1
- #define _OSCSTAT_T1OSCR_LENGTH 0x1
- #define _OSCSTAT_T1OSCR_MASK 0x80
复制代码me too.
MPLAB X + PICC 挺好用。
#include "pic.h"
#include <htc.h>
__CONFIG(FOSC_INTOSC & WDTE_OFF & PWRTE_OFF & MCLRE_ON & CP_OFF & CPD_OFF & BOREN_OFF & CLKOUTEN_OFF & IESO_ON & FCMEN_OFF);
__CONFIG(WRT_OFF & PLLEN_ON & STVREN_ON & BORV_LO & LVP_OFF);
现在正在用PIC16F1824做项目,8路AD全用了,还有一路PWM。
好的,谢谢。我试试看。
#include <pic16f1824.h> //调用头文件,
#include "pic.h"
#include <htc.h>
__CONFIG(FOSC_INTOSC & WDTE_OFF & PWRTE_OFF & MCLRE_ON & CP_OFF & CPD_OFF & BOREN_OFF & CLKOUTEN_OFF & IESO_ON & FCMEN_OFF);
__CONFIG(WRT_OFF & PLLEN_ON & STVREN_ON & BORV_LO & LVP_OFF);
编译不成功:
Build E:PICPIC_1824EPIC_1824E for device 16F1824
Using driver C:Program Files (x86)Microchipxc8v1.12inxc8.exe
Make: The target "E:PICPIC_1824Emain.p1" is up to date.
Executing: "C:Program Files (x86)Microchipxc8v1.12inxc8.exe" -oPIC_1824E.cof -mPIC_1824E.map --summary=default,-psect,-class,+mem,-hex --output=default,-inhx032 main.p1 --chip=16F1824 "-IC:Program Files (x86)Microchipxc8v1.12include" "-IC:Program Files (x86)HI-TECH SoftwarePICCstd9.60include" -P --runtime=default,+clear,+init,-keep,+osccal,-download,-resetbits,-stackcall,-config,+clib,+plib --opt=default,+asm,-debug,-speed,+space,9 --warn=0 -N255 -D__DEBUG=1 --debugger=pickit3 -Bsmall --double=32 --float=32 --addrqual=ignore -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Microchip MPLAB XC8 C Compiler V1.12
Copyright (C) 2012 Microchip Technology Inc.
License type: Node Configuration
Warning [1273] ; . Omniscient Code Generation not available in Free mode
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "FCMEN_OFF"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "IESO_ON"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "CLKOUTEN_OFF"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "BOREN_OFF"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "CPD_OFF"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "CP_OFF"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "MCLRE_ON"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "PWRTE_OFF"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "WDTE_OFF"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 339. undefined symbol "FOSC_INTOSC"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 343. undefined symbol "LVP_OFF"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 343. undefined symbol "BORV_LO"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 343. undefined symbol "STVREN_ON"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 343. undefined symbol "PLLEN_ON"
Error [800] C:UsersguoliangAppDataLocalTempss2k.; 343. undefined symbol "WRT_OFF"
(908) exit status = 1
********** Build failed! **********
一周热门 更多>