嵌入式 CC2543 RF中断详解

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31389903/article/details/51554568

TI CC2543 miniBLE 芯片

因为公司要求,选定的芯片是TI 的CC2543,这款芯片很少人用,资料也就是官方的资料和例程,下面是我自己根据这几天看的例程,总结一下,如果哪里不对,欢迎大家斧正。下面用的是TI给的例程,GenericBroadcast 程序。


首先我们来看看官方文档中的RF中断是怎么描述的:

23.2 Interrupts
The radio is associated with two interrupt vectors on the CPU. These are the RFERR interrupt (interrupt0) and the RF interrupt (interrupt 12) with the following functions
• RFERR: Error situations in the radio are signaled using this interrupt
• RF: Interrupts coming from normal operation are signaled using this interrupt
The RF interrupt vector combines the interrupts in RFIF. Note that these RF interrupts are rising-edge triggered. Thus, an interrupt is generated when, for example, the TASKDONE status flag in the RFIRQF1 register goes from 0 to 1. The RFIF interrupt flags are described in Section 23.2.1.

这个radio在CPU中有两个中断向量,分别是RFERR interrupt (interrupt0)和RF interrupt (interrupt 12) ,功能如上所说。需要注意的是RF中断是上升沿触发。所以当中断发生的时候,举个例子,在RFIRQF1 寄存器中的TASKDONE的状态符号位需要从0置成1,。这只是一个条件,RF中断发生需要满足几个条件,下面会说明。

23.2.1 Interrupt Registers
Two main interrupt control SFR registers are used to enable the RF and RFERR interrupts. These are the following:
• RFERR: IEN0.RFERRIE
• RF: IEN2.RFIE
Two main interrupt flag SFR registers hold the RF and RFERR interrupt flags. These are the following:
• RFERR: TCON.RFERRIF
• RF:S1CON.RFIF
The two interrupts generated from RF core are a combination of several sources within the RF core. Each of the individual sources have their own enable and interrupt flags in RF core. Flags can be found in RFIRQF0, RFIRQF1 and RFERRF. Interrupt enable masks can be found in RFIRQM0, RFIRQM1 and RFERRM.

The interrupt enable bits in the mask registers are used to enable individual interrupt sources. Note that masking an interrupt source does not affect the updating of the corresponding status in the flag registers.

Due to the use of individual interrupt masks in RF core, the interrupts coming from RF core has two layered masking and care must be taken when processing these interrupts. The procedure is described below.

To clear an interrupt from RF core one needs to clear two flags. Both the flag set in RF core and the one set in the main interrupt flag SFR registers, S1CON or TCON (depending on which interrupt is triggered). If a flag is cleared in RF core and there are other unmasked flags standing, the main interrupt flag is set.
Exiting the interrupt service routine with the main interrupt flag set causes the interrupt service routine to be executed again.
TIP: For proper handling of interrupts in ISRs, the following is advised:
• At the start of the ISR, read and store the RF core flags
• Process the interrupts
• Clear the main interrupt flag
• Clear the processed RF core flags. It is important that this is done in one single operation.


能做这行的英语应该都是不错的。这里需要注意的是,中断有两个,一个是RF core的中断使能和flag,一个是 main interrupt,举个例子,看下面图会更清晰一点.把断点断在刚进去RF中断里面,看看enable和flag的配置。其中可以看到RFIRQM1_TASKDONE = 1;RFIRQF1_TASKDONE = 1;RFIRQF1_TXDONE = 1;这里具体名称的,就是属于RF core的中断使能。在这里,TASKDONE是当LLE从TXFIFO里读取完全数据包后会自动引发TASKDONE interrupt,我的理解是自动置1的意思,TXDONE interrupt 发生芯片规格书上面也有写,当达到什么条件,也会自动的置1的。




再来看下图,下面的S1CON中的RFIF_0和RFIF_1同时置1,这个就是属于 main interrupt的中断符号标志位。





注意:当清除flag的时候,必须清掉所有 RF core 里面的flag,如果有一个没有清掉, the main interrupt flag都会自动设置,从而又进入一次中断。所以在RF中断服务中确保已经把 RF core 里面的flag全部清0.


如果想要中断发生,首先要满足一下的条件,RF中断有如下图的(我举中间的RF中断说明,RFIRQF1开头)RFIRQM1的enable和RFIE的enable要置1使能(已经在 miniBleInit()这个函数中进行了初始化),RFIF_0和 RFIF_1同时置1(这个我猜的是只要有 RF core的flag置1了,RFIF_0和RFIF_1系统就会自动置成1,如果想要自己设置,自己设置其中一个就可以了)。



仅作为学习交流使用,如有不对,欢迎斧正,我的QQ号:525163556



猜你喜欢

转载自blog.csdn.net/qq_31389903/article/details/51554568
今日推荐