__attribute __(((__ interrupt__,no_auto_psv))做些什么? [英] What does __attribute__((__interrupt__, no_auto_psv)) do?

查看:199
本文介绍了__attribute __(((__ interrupt__,no_auto_psv))做些什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

__ attribute __ 指令或宏来自GCC,但 __ interrupt __ no_auto_psv 不是,它特定于硬件.因此,GCC编译器如何理解 __ interrupt __ no_auoto_psv ,我进行了搜索,但未在其他任何地方找到任何声明.

__attribute__ directive or macro is from GCC but __interrupt__ and no_auto_psv is not , it's specific to a hardware. So, how does GCC Compiler understand __interrupt__ and no_auoto_psv, I searched and didn't find any declaration in anywhere else.

那么基本上 _T1Interrupt 函数不带任何参数,什么也不返回,但是具有上述属性?

So basically the _T1Interrupt function takes no argument and return nothing but has the above attribute?

推荐答案

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

In particular, these attributes are platform-specific extensions used in the Microchip XC16 compiler for 16-bit PIC24 and dsPICs.

属性本质上是添加到编译器解析树中的额外信息.它们存在于C语言语义之外,并在其中提供其他信息,编译器可使用这些信息来始终符合您的期望.在这种情况下, __ interrupt __ 告诉它将功能视为ISR(功能序言和结尾处的功能与正常功能略有不同:dsPIC ISR使用 RETFIE 返回指令,而不是. RETURN (用于正常功能),以及 no_auto_psv 控制编译器是否设置 PSVPAG 寄存器:

Attributes are essentially extra information added to the parse tree of a compiler. They exist outside the C language semantics and are there to provide additional information that the compiler uses to act consistently with your expectations. In this case __interrupt__ tells it to treat the function as an ISR (with slightly different function prolog and epilog than a normal function: dsPIC ISRs use the RETFIE return instruction, vs. RETURN for normal functions), and no_auto_psv controls whether the compiler sets the PSVPAG register:

使用no_auto_psv属性会省略代码,该代码会将PSVPAG值重新初始化为自动psv变量(常量或放置在空间auto_psv中的变量)的默认值.如果您的代码没有显式修改PSVPAG寄存器,也没有使用编译器管理的 psv prog 限定符来修改PSVPAG寄存器,则使用no​​_auto_psv是安全的.另外,如果您的中断服务例程(或中断服务例程调用的函数)未使用任何const或空间auto_psv变量,则可以安全地使用no_auto_psv.

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)

这篇关于__attribute __(((__ interrupt__,no_auto_psv))做些什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆