你(们)好
有3个 ISR 函数、我在项目中将其称为 A/B/C。 它们的切换源是不同的、时序是随机的。 但是、A 应该比 B 和 C 具有高优先级。我想知道、无论 B 和 C 在运行、如何设置具有高优先级的 A。
供参考。 我正在使用 driverlib
BR
HK Woo
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.
你(们)好
有3个 ISR 函数、我在项目中将其称为 A/B/C。 它们的切换源是不同的、时序是随机的。 但是、A 应该比 B 和 C 具有高优先级。我想知道、无论 B 和 C 在运行、如何设置具有高优先级的 A。
供参考。 我正在使用 driverlib
BR
HK Woo
您好、HK Woo、
感谢您的提问。 请参阅以下嵌套指南、它将引导您完成(1)中断的自定义优先级和(2)中断嵌套:
https://software-dl.ti.com/C2000/docs/c28x_interrupt_nesting/html/index.html
在 interrupts 文件夹(interrupts_ex1_sw_Prioritization)下的 driverlib 中还有一个用于此操作的软件示例
此致、
Vince
抱歉...我在查看 h 文件后仍然不理解。 我在 c 中没有看到任何代码引用此 h 文件。 实际上、我 希望 EPWM1具有高优先级。 它的运行频率@ 300K Hz。 另一个 EPWM2的运行频率@ 586Hz。 它们充当计时器。 我不知道它们的中断属于哪个中断组。
我的想法是、无论 EPWM2 ISR 中的代码在运行、只要 EPWM1产生中断、就必须立即运行 EPWM1 ISR
下面是我在 EPWM2的 ISR 中的代码
uint16_t TempPIEIER;
TempPIEIER = PieCtrlRegs.PIEIER2.all;
IER |= M_INT1;
IER &= MINT1; //设置"全局"优先级
PieCtrlRegs.PIEIER2.all &= MG1_1; //设置“组”优先级
PieCtrlRegs.PIEACK.ALL = 0xFFFF; //启用 PIE 中断
asm (" NOP"); //等待一个周期
EINT;
我的代码
INTERRUPT_clearACKGROUP (INTERRUPT_ACK_Group3);
Dint;
HWREGH (PIECTRL_BASE + PIE_O_IER2)= TempPIEIER;
我在 EPWM2 ISR 中使用上述代码进行嵌套。 EEPWM1 ISR 中。 我在 EPWM1 ISR 中切换调试引脚、以监控它是否以300K Hz 的频率运行。 结果发现、脉冲宽度有时会延长3.3us、例如4.0us。 在 EPWM2 ISR 代码中嵌套似乎不起作用。
从 interrupt_ex3_sw_prioration.c 中删除
//! For most applications, the hardware prioritizing of the interrupts is //! sufficient. For applications that need custom prioritizing, this example //! illustrates how this can be done through software.User specific priorities //! can be configured in sw_prioritized_isr_level.h header file.
来自 sw_prioritized_isr_levels.h
// // Set "Global" Interrupt Priority Level (IER register): // // The user must set the appropriate priority level for each of the CPU // interrupts. This is termed as the "global" priority. The priority level // must be a number between 1 (highest) to 16 (lowest). A value of 0 must // be entered for reserved interrupts or interrupts that are not used. // // Note: The priority levels below are used to calculate the IER register // interrupt masks MINT1 to MINT16. // // Note: The priority levels shown here may not make sense in a // real application. This is for demonstration purposes only!!! // // The user should change these to values that make sense for // their application. // // 0 = not used // 1 = highest priority // ... // 16 = lowest priority // #define INT1PL 16 // Global Priority for Group1 Interrupts #define INT2PL 0 // Global Priority for Group2 Interrupts #define INT3PL 0 // Global Priority for Group3 Interrupts #define INT4PL 0 // Global Priority for Group4 Interrupts #define INT5PL 0 // Global Priority for Group5 Interrupts #define INT6PL 0 // Global Priority for Group6 Interrupts #define INT7PL 0 // Global Priority for Group7 Interrupts #define INT8PL 0 // Global Priority for Group8 Interrupts #define INT9PL 0 // Global Priority for Group9 Interrupts #define INT10PL 0 // Global Priority for Group10 Interrupts #define INT11PL 0 // Global Priority for Group11 Interrupts #define INT12PL 0 // Global Priority for Group12 Interrupts #define INT13PL 7 // Global Priority for INT13 (TINT1) #define INT14PL 1 // Global Priority for INT14 (TINT2) #define INT15PL 0 // Global Priority for DATALOG #define INT16PL 0 // Global Priority for RTOSINT
// // Set "Group" Interrupt Priority Level (PIEIER1 to PIEIER12 registers): // // The user must set the appropriate priority level for each of the PIE // interrupts. This is termed as the "group" priority. The priority level // must be a number between 1 (highest) to 16 (lowest). A value of 0 must // be entered for reserved interrupts or interrupts that are not used. // // Note: The priority levels below are used to calculate the following // PIEIER register interrupt masks: // MG1_1 to MG1_16 // MG2_1 to MG2_16 // MG3_1 to MG3_16 // MG4_1 to MG4_16 // MG5_1 to MG5_16 // MG6_1 to MG6_16 // MG7_1 to MG7_16 // MG8_1 to MG8_16 // MG9_1 to MG9_16 // MG10_1 to MG10_16 // MG11_1 to MG11_16 // MG12_1 to MG12_16 // // Note: The priority levels shown here may not make sense in a // real application. This is for demonstration purposes only!!! // // The user should change these to values that make sense for // their application. // // 0 = not used // 1 = highest priority // ... // 16 = lowest priority // #define G1_1PL 0 // ADCA1_INT #define G1_2PL 0 // Reserved #define G1_3PL 0 // ADCC1_INT #define G1_4PL 0 // XINT1_INT #define G1_5PL 0 // XINT2_INT #define G1_6PL 0 // Reserved #define G1_7PL 4 // TIMER0_INT #define G1_8PL 0 // WAKE_INT #define G1_9PL 0 // Reserved #define G1_10PL 0 // Reserved #define G1_11PL 0 // Reserved #define G1_12PL 0 // Reserved #define G1_13PL 0 // Reserved #define G1_14PL 0 // Reserved #define G1_15PL 0 // Reserved #define G1_16PL 0 // Reserved #define G2_1PL 0 // EPWM1_TZ_INT #define G2_2PL 0 // EPWM2_TZ_INT #define G2_3PL 0 // EPWM3_TZ_INT #define G2_4PL 0 // EPWM4_TZ_INT #define G2_5PL 0 // EPWM5_TZ_INT #define G2_6PL 0 // EPWM6_TZ_INT #define G2_7PL 0 // EPWM7_TZ_INT // ETC...
请尝试不修改运行此示例、以查看它是否在您的系统上工作。 然后一次修改一点、以了解如何执行中断嵌套和优先级排序。
您好!
有关中断延迟的详细信息、请参阅此主题:
此致、
Vince