XC8管脚定义
刚接触xc8,以前一直汇编,入门问题多多,大侠们不要笑话。话说一直以来#defineled portc,4用的溜溜的,现在C上不会了啊
#define offcaLATDbits.LATD0;
while(1)
{
LATD=offco;
LATBbits.LATB0=1;
offca=1;
}
编译
清除已成功 (总时间: 17ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make: Entering directory 'D:/microchip/CTEST'
make-f nbproject/Makefile-default.mk dist/default/production/CTEST.production.hex
make: Entering directory 'D:/microchip/CTEST'
"C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe"-mcpu=18LF45K22 -c-fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default-msummary=-psect,-class,+mem,-hex,-file-ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mainC.p1 mainC.c
mainC.c:94:6: error: expected expression
offca=1;
^
1 error generated.
(908) exit status = 1
nbproject/Makefile-default.mk:106: recipe for target 'build/default/production/mainC.p1' failed
make: Leaving directory 'D:/microchip/CTEST'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make: Leaving directory 'D:/microchip/CTEST'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** Error 1
make: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
我想用个代号表示某个管脚该怎样啊,同志们
#define PIN01<<0
#define PIN11<<1
....
LATD |= PIN0;// 设置
LATD&= ~PIN0;// 清除 你的define后面多了个 ;号吧
竟然真的是多了个;的事,坑死了,多谢
刚学C,入门问题多多,一个中断入口就折腾一天
自己在头文件或者相关的文件中做个宏定义就行了 哈哈 感觉编程风格还是有汇编的影子 楼主可以看看相关的头文件 肯定有可以借鉴的地方 楼主#define offcaLATDbits.LATD0;这个语句后边不应该有分号 wyjie 发表于 2022-11-5 20:30
竟然真的是多了个;的事,坑死了,多谢
这就长记性了以后肯定不能再有分号了 妥妥的语法错误,这个以后肯定不能发生了 为什么有时候报错的并是不出错的那一行呢
页:
[1]