This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

tms320c6748中断嵌套问题

在文档SPRUFK5里面有一句"since any interrupt service routine can be atomic(not nestable),the cpu interrupt priority only applies to pending interrupts",有人说c6748硬件上只支持可屏蔽中断和不可屏蔽中断之间的嵌套!我想问如果是不可屏蔽中断之间嵌套,怎么实现,比如INT4中断优先级高于INT5,如果在执行INT5的中断服务函数时,INT4中断来了,会先去执行INT4中断服务函数么?执行完了再返回int5中断服务函数么?如果int4中断函数正在执行当中,int5中断来了是否就不会响应int5中断?

  • INT4,5这些属于可屏蔽中断,如果INT5中断服务函数里INT4中断是使能的话,如果INT4中断来了,回去执行INT4中断服务程序,执行完了再返回INT5。可以看一下下面文档的中断嵌套介绍。

    5.6.2 Nested Interrupts
    http://www.ti.com/lit/ug/sprufe8b/sprufe8b.pdf

     

  • butterworth lan 说:
    有人说c6748硬件上只支持可屏蔽中断和不可屏蔽中断之间的嵌套!

    这人说的是对的,硬件上不可屏蔽中断指的是NMI,它是可以打断普通中断的,优先级最高,它不受GIE控制,一直是使能的,其返回指令是NRP,不是IRP,所以不需要软件做额外处理。

    butterworth lan 说:
    我想问如果是不可屏蔽中断之间嵌套,怎么实现,

    不可屏蔽中断只有一个NMI,所以你后面的描述都不正确了。

    butterworth lan 说:
    比如INT4中断优先级高于INT5,如果在执行INT5的中断服务函数时,INT4中断来了,会先去执行INT4中断服务函数么?执行完了再返回int5中断服务函数么?如果int4中断函数正在执行当中,int5中断来了是否就不会响应int5中断?

    不会。正在执行的中断不会被打断,优先级只针对于当有多个pending状态的中断时先执行哪一个时有效。所以要理解这句话的意思:the cpu interrupt priority only applies to pending interrupts。

  • 我看了这个文档,其中说到可以通过软件实现可屏蔽中断的嵌套,中断服务函数中必须有以下操作1.先保存IRP或者NRP;2.保存PGIE;3.保存ITSR;4.GIE设置为1;在返回中断服务函数前还要分别恢复上述相关寄存器的值!

    这些操作需要做么?还是说INT5中断服务函数里面只要INT4中断使能,在执行INT5中断服务函数和INT4中断服务函数时就可以自动完成相应上述操作?

  • 输入错了,想说的是可屏蔽中断;

    如果在执行INT5中断服务函数时不会响应INT4中断,sprufe8b.pdf手册里面说的可实现软件的可屏蔽中断嵌套该怎么理解?

  • 这些操作需要在中断服务函数代码做。

  • 硬件上不支持可屏蔽中断嵌套,所以要做的话就需要通过软件实现。

  • TI官方提供有这方面的例程么?

    有更高优先级中断产生后,开始保存通用寄存器、PC指针、堆栈指针、中断状态、返回指针等信息
    然后进入中断服务函数,返回后再进行低优先级中断服务函数 ......
    而且要自己实现中断优先级的调度

    感觉做起来比较复杂

  • 没有。

    如果你用DSP/BIOS或SYS/BIOS中断的dispatch就很方便实现。

  • 兄弟,你说错了, 正在执行的可屏蔽中断(非NMI)可以被其他的可屏蔽中断打断,比如,如果当前正在执行INT5的中断服务函数,如果INT4来了,会把INT5打断,并且在INT4处理完后,会返回到INT5被打断的位置,你所说的不会被打断,只是因为:一般情况下,我们在实现INT5的中断服务函数时,一进去就把调用了disableINT屏蔽了所有中断。如果不做这一步是可以被打断的。

    具体请参考:sprufe8b.pdf  以下描述:


    5.6.2 Nested Interrupts
    Generally, when the CPU enters an interrupt service routine, interrupts are disabled. However, when the
    interrupt service routine is for one of the maskable interrupts (INT4-INT15), an NMI can interrupt
    processing of the maskable interrupt. In other words, an NMI can interrupt a maskable interrupt, but
    neither an NMI nor a maskable interrupt can interrupt an NMI.
    Also, there may be times when you want to allow an interrupt service routine to be interrupted by another
    (particularly higher priority) interrupt. Even though the processor by default does not allow interrupt service
    routines to be interrupted unless the source is an NMI, it is possible to nest interrupts under software
    control. To allow nested interrupts, the interrupt service routine must perform the following initial steps in
    addition to its normal work of saving any registers (including control registers) that it modifies:
    1. The contents of IRP (or NRP) must be saved
    2. The contents of the PGIE bit must be saved
    3. The contents of ITSR must be saved
    4. The GIE bit must be set to 1

    Prior to returning from the interrupt service routine, the code must restore the registers saved above as
    follows:
    1. The GIE bit must be first cleared to 0
    2. The PGIE bit saved value must be restored
    3. The contents of ITSR must be restored
    4. The IRP (or NRP) saved value must be restored




  • 你好,请问你实现了在c6748上的中断嵌套吗?普通的嵌套应该没问题,优先级嵌套不知能否实现