勘误表显示:
Unpredictable code execution can occur if one of the hardware-clear-able IFGs UCSTTIFG, UCSTPIFG or UCNACKIFG is set while the global interrupt enable is set by software (GIE=1). This erratum is triggered if ALL of the following events occur in following order: 1. Pending Interrupt: One of the UCxIFG=1 AND UCxIE=1 while GIE=0 2. The GIE is set by software (e.g. EINT) 3. The pending interrupt is cleared by hardware (external I2C event) in a time window of 1 MCLK clock cycle after the "EINT" instruction is executed. Workaround: Disable the UCSTTIE, UCSTPIE and UCNACKIE before the GIE is set. After GIE is set, the local interrupt enable flags can be set again.
进入 ISR 后、GIE 会在硬件中自动清零、而在"reti"时、最后一个状态寄存器值会从堆栈中弹出、从而重新启用 GIE。 这是与 USCI39相关的问题、还是通过"reti"设置 GIE 不会导致此错误?
slau646f 说:
硬件乘法例程在运行时禁用中断、并在中断完成时恢复之前的中断状态。 这使得它们在中断处理程序内部以及在正常代码中使用是安全的。
当在我控制的软件中重新启用中断时、我可以应用权变措施。 但是,如果 gcc 生成的代码调用 CRT 时出现中断状态,我就没有这样的控制。 我无论如何都不会在中断中执行乘法运算、到目前为止、我还没有看到使用 HW 乘法器加速位移运算(因为缺少桶形移位器)。 我想我的问题有两个方面:
- 是否有办法打破 GCC 禁用乘法中断的习惯、或者:
- USCI39权变措施是否需要这样做? 即:在-O3上、gcc 将 R2压入堆栈、并使用"pop R2"重新启用中断(如果启用了中断)。 在-OS 上、函数__mulhsi2使用 reti 重新启用 GIE