c - __attribute__((__interrupt__, no_auto_psv)) 是做什么的?

标签 c gcc interrupt pic

void __attribute__((__interrupt__, no_auto_psv)) _T1Interrupt(void) // 5 Hz

__attribute__ 指令或宏来自 GCC 但 __interrupt__no_auto_psv 不是,它特定于硬件。那么,GCC Compiler 是如何理解__interrupt__no_auoto_psv 的,我搜索了一下,在其他地方也没有找到任何声明。

所以基本上 _T1Interrupt 函数不带参数也不返回任何东西,但具有上述属性?

最佳答案

特别是,这些属性是 Microchip XC16 编译器中用于 16 位 PIC24 和 dsPIC 的特定于平台的扩展。

属性本质上是添加到编译器解析树中的额外信息。它们存在于 C 语言语义之外,用于提供编译器使用的附加信息,以便与您的期望保持一致。在这种情况下,__interrupt__ 告诉它将函数视为一个 ISR(函数序言和结尾与普通函数略有不同:dsPIC ISR 使用 RETFIE 返回指令,而RETURN 用于正常功能),no_auto_psv 控制编译器是否设置 PSVPAG 寄存器:

The use of the no_auto_psv attribute omits code that will re-initialize the PSVPAG value to the default for auto psv variables (const or those placed into space auto_psv). If your code does not modify the PSVPAG register either explicitly or using the compiler managed psv or prog qualifiers then the use of no_auto_psv is safe. Also, if your interrupt service routine (or functions called by your interrupt service routine) does not use any const or space auto_psv variables, then it is safe to use no_auto_psv.

(来自 http://www.microchip.com/forums/m394382.aspx)

关于c - __attribute__((__interrupt__, no_auto_psv)) 是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17277822/

相关文章:

c++ - Eclipse 中的 Arduino 端口寄存器不工作

c++ - int 位运算

c - 如何从c中的动态数组中访问数据?

gcc - libiconv 和 MacOS

c++ - 左值初始化失败

linux - 设置中断标志 (sti) 使 linux 内核崩溃

c - 使用 poll() 检查文件修改

optimization - Rust 优化输出循环?

python - 在系统调用期间捕获/阻塞 SIGINT

arduino - Arduino AttachInterrupt()似乎运行了两次