pic - 无法在代码中运行中断功能不起作用
问题描述
这部分代码有问题:void interrupt ISR_Timer0_Int
mplabs x ide 5.10 显示错误:
newmain.c:26:6:错误:变量的类型不完整'void'
newmain.c:26:15:错误:预期';' 在顶级声明者之后
我正在使用 XC8 V2 编译器,它将进入 PIC18f4550
代码:
void interrupt ISR_Timer0_Int() // Timer0 Interrupt Service Routine (ISR)
{
if (INTCONbits.TMR0IF) // TMR0IF:- Timer0 Overflow Interrupt Flag Bit
// 1 = TMR0 reg has overflowed
// 0 = TMR0 reg has not overflowed
{
TMR0H = 0xED; // Timer0 start value = 0x48E5 for 0.1 second
TMR0L = 0x4C;
if (j <= 7) { //limit up to 7
j++; // Increase count by 1
PORTD = j; // Output to Demultiplexer
}
else {
j = 0; // Reset count aftwr it hit 7
PORTD = j; // Output to Demultiplexer
}
INTCONbits.TMR0IF = 0; // Reset TMR0IF to "0" since the end of
// the interrupt function has been reached
}
}
解决方案
新的编译器改变了语法。更多信息和文档链接可以在这里找到https://www.microforum.cc/topic/5-i-used-to-use-to-locate-variables-but-since-xc8-20-this -不再工作/
您可以通过将编译器设置回 C90 模式或使用新的中断语法来编译旧代码,如该链接中所述。
推荐阅读
- spring-boot - Gradle 变量不在复制和重命名任务的范围内
- java - 无法使用数据库(mysql)中的数据刷新 Tableview
- loops - Java 1 的作业
- python - 如何提高图像分类模型中的模型精度
- sql - SQL Server - GROUP BY 超过 1000 万行达到性能
- swift - 如何获取正在运行的进程的完整列表
- java - 无法在谷歌地图中绘制路线
- javascript - 来自服务器的哪个响应是需要具有安全标头的响应
- node.js - Webhook 调用失败。错误:500 内部服务器错误 | 对话流 | 火力基地
- scala - 无法让 pureconfig 反序列化嵌套案例类