嵌入式 CC2543 RF中断详解

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



)EV1527中断法解码 ① 设定定时器中断时间,设定为 80us,80us 进入中断进行解码。具体中断时间多少由自己 软件设定,但是中断时间不能太大。 ② 设定同步码解码范围,同步码定为 5.6ms - 16ms。进入中断判断到低电平,低电平判断 一直累加 Count_Lead++,累积低电平的采集时间,判断到高电平,就判断此时 Count_Lead 的值是否在 70 跟 200之间。(备注:5.6ms/80us=70 16ms/80us=200)。 ③ 引导头通过进入数据判断,刚开始是数据高电平,累积高电平的时间 Count_Data_Hi++, 当判断到低电平时候,判断 Count_Data_Hi 是否在 80us -2.4ms 之间。这还没进行数据 0 跟 1 的区分,先把 Count_Data_Hi 的值保存在 Hi_Cnt 面。 (备注:80us/80us=1 2.4ms/80us=30)。 ④ 高电平判断通过,开始判断低电平,累积低电平的时间 Count_Data_lo++,当判断到高电 平时候,判断 Count_Data_Lo 是否在 80us -2.4ms 之间。这还没进行数据 0 跟 1 的区分, 先把 Count_Data_Lo 的值保存在 Lo_Cnt 面。 (备注:80us/80us=1 2.4ms/80us=30)。 ⑤ 对 0 跟 1 进行区分,把 24bit 数据整理成三个 byte,存在数组 RfData[0],RfData[1], RfData[2]数组面。 ⑥ 进行相应功能码的操作。 具体解码方法参考例子程序,因为不同的震荡电阻,1527 出来的编码长度不同,例子 程序是参考 1 lck=100us 波形来做的。具体时间参数可以根据自己的 1527 发射实际长度来 编写。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值