F28069教程3-中断 PIE
中断 C2000设备 PIE模块 中断服务例程 中断优先级
文章目录
- Interrupts
- What are interrupts?
- Interrupt Architecture within C2000 devices
- Peripheral Interrupt Expansion (PIE)
- PIE Block Initialization
- Interrupt Processing
https://dev.ti.com/tirex/explore/content/c2000_academy_2.00.01.41_all/modules/Module_3_Deep_Dive/module_3_deep_dive.html
PIE:Peripheral Interrupt Expansion block
Interrupts
What are interrupts?
An interrupt is a response by the processor to an event that needs attention. The processor executes instructions that are defined within the interrupt service routine (ISR) as soon as is capable, and then goes back to normal operational tasks. Unlike idle loops where code waits for an event to occur, interrupts provide the opportunity to have non-idle code loops that execute based on the CPU’s availability and priority of tasks.
Interrupt Architecture within C2000 devices
Refer to the ‘Device Interrupt Architecture’ figure of the device’s Technical Reference Manual (TRM) for a visual representation of the interrupt architecture described below.
The internal interrupt sources include the general purpose timers 0, 1, and 2, and all of the peripherals on the device.
External interrupt sources include the five external interrupt lines. From the Input X-BAR, INPUT4 maps to XINT1, INPUT5 maps to XINT2, INPUT6 maps to XINT3, INPUT13 maps to XINT4, and INPUT14 maps to XINT5.
The Peripheral Interrupt Expansion block, known as the PIE block, is used to expand the core interrupt capability. Timer 0 is directly connected to the PIE block as well as the WAKEINT signal from the Watchdog module. For dual core devices, each core has its own PIE block and the XINTx signals are shared between the two cores as well as the peripheral interrupts, and inter-processor (IPC) signals.
The core has 14 interrupt lines (for dual core devices, each core has its own set of 14 interrupt lines). Interrupts 1-12 come from the PIE block, interrupt 13 is mapped to Timer 1 and interrupt 14 is mapped to Timer 2. The NMI module is directly connected to the NMI interrupt which is mapped to the core.
Peripheral Interrupt Expansion (PIE)
A Peripheral Interrupt Expansion (PIE) module multiplexes up to sixteen peripheral interrupts into each of the twelve CPU interrupt lines, further expanding support for up to 192 peripheral interrupt signals.
The PIE module also expands the interrupt vector table, allowing each unique interrupt signal to have its own interrupt service routine (ISR), permitting the CPU to support a large number of peripherals.
The PIE block consists of 12 groups. Within each group, there are sixteen interrupt sources. Each group has a PIE interrupt enable register and a PIE interrupt flag register.
Any interrupt lines that do not go through the PIE block are directly connected to the CPU like Timer 1/2 and NMI.
To view the PIE block mapping refer to the ‘PIE Channel Mapping’ table within the device’s Technical Reference Manual (TRM). Figure 4 shows an example of the PIE channel mapping for the F2838x device.
The PIE assignment table maps each peripheral interrupt to the unique vector location for that interrupt service routine. The interrupt numbers on the left (rows) represent the twelve core group interrupt lines and the interrupt numbers across the top (columns) represent the channel number within the core group interrupt line.
Each of the 12 PIE groups has a 16-bit flag register (PIEIFRx), a 16-bit enable register (PIEIERx), and a bit field in the PIE acknowledge register (PIEACK) which acts as a common interrupt mask for the entire group.
For a peripheral interrupt to propagate to the CPU, the appropriate PIEIFR must be set, the PIEIER enabled, the CPU IFR set, the IER enabled, and the INTM enabled. Note that some peripherals can have multiple events trigger the same interrupt signal, and the cause of the interrupt can be determined by reading the peripheral’s status register.
The enable PIE bit in the PIECTRL register is used to activate the PIE module. Note that when using the Driverlib function to enable and disable interrupts, both the PIEIER and CPU core IER registers are modified.
Driverlib functions to modify both the PIEIER and core IER registers:
Interrupt_enable(interruptNumber);
Interrupt_disable(interruptNumber);
PIE Block Initialization
Two separate functions are called to initialize the interrupt module and PIE block.
Interrupt_initModule();
Interrupt_initVectorTable();
During processor initialization the interrupt vectors, as mapped in the PIE interrupt mapping table, are copied to the PIE RAM and then the PIE module is enabled by setting ENPIE to ‘1’.
When the CPU receives an interrupt, the vector address of the ISR is fetched from the PIE RAM, and the interrupt with the highest priority that is both flagged and enabled is executed.
Priority is determined by the location within the interrupt vector table. The lowest numbered interrupt has the highest priority when multiple interrupts are pending.
In summary, the PIE initialization code flow is as follows:
-
After the device is reset and execution of the boot code is completed, the selected boot option determines the code entry point.
-
The CodeStartBranch.asm file has a long branch instruction to the entry point of the runtime support library. After the runtime support library completes execution, main is called.
-
In main, a function is called to initialize the interrupt process and enable the PIE module.
-
When the CPU receives an interrupt, the vector address of the ISR is fetched from the PIE RAM, and the interrupt with the highest priority that is both flagged and enabled is executed.
-
Priority is determined by the location within the interrupt vector table.
天堑小雨润如酥: yaw要用加速计处理下吧
Wlof_grey: 想问一下大佬,报错2怎么解决啊
buaalyh: 感谢作者分享,这里指出几条个人发现的,存疑的地方:公式(1)矢量部分是否需要加负号?由于四元数与旋转矩阵变换形式常用格式与式(6)不一致,导致式(7-9)存在一些不同;按照参考文献里面的内容,式(11)是不是表示传感器坐标系相对于世界坐标系的姿态变化速率?
guofeng509: 您好,uitools.h和uitools.c两个文件在哪里能找到
chenjs2019: tinyxml无法处理dtd,所以无法处理标准的svg。可以用msxml,生成的exe文件很小。