PlatformIO搭配clion或vscode踩坑记录
好吧,我是“颜狗”,⚠keil⚠
缺点就是不支持调试52rc https://docs.platformio.org/en/latest/boards/intel_mcs51/STC89C52RC.html#

sdcc其实有调试工具sdcdb,但我觉得那是一坨shit(难道我的打开方式不对?)
PlatformIO开发51
官方手册 https://docs.platformio.org/page/projectconf.html
platformio.ini教程 https://www.bilibili.com/video/BV16X4y1m7AK/
platformio.ini 能用配置
| [platformio] | 
一些博客教程
刚开始补全不好用改下下面头文件
8052.h

8051.h

愉快补全

keil,sdcc库不同点
Migration Keil 2 SDCC:https://www.infineon.com/dgdl/AP0806510_XC800_Migration_Keil_2_SDCC.pdf?folderId=db3a30431375fb1a01138c57204603bd&fileId=db3a304314dca389011517efc5860d61&ack=t
sdcc manual https://sdcc.sourceforge.net/doc/sdccman.pdf
中断回调函数定义中x标识的是中断号
比如
| 中断号 | 含义 | 
|---|---|
| 0 | 外部中断0 | 
| 1 | 定时器中断0 | 
| 2 | 外部中断1 | 
| 3 | 定时器中断1 | 
| 4 | 串口中断 | 
| sdcc | keil | |
|---|---|---|
| 头文件 | 8052.h/8051.h | reg52.h/reg51.h | 
| 端口控制口定义 | #define LED1 P2_0 | sbit LED1 = P2 ^ 0; | 
| 中断回调定义 | void time1() __interrupt(x) {} | void time1() interrupt 3 using 2 | 
keil c 的中断
void SerialComm(void ) interrupt 4 ;
{
}
sdcc 的中断
void SerialComm(void) __interrupt 4;
{
}
sdcc 没有_nop()_ , 可用如下自定义宏代替: #define _nop()_ __asm NOP __endasm ps: sdcc里用__asm xxx __endasm来做内联汇编
| 
 | 
这种宏定义的方式在SDCC中不支持。可以替换为以下方式:
| 
 | 
在反转引脚时,不要使用取反(P00 = ~P00),而应该使用非(P00 = !P00)运算;因为 sdcc 会默认进行类型提升,然后进行取反
sdcc简单示例