You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by WangJiacheng <ji...@icloud.com> on 2016/11/08 04:19:40 UTC

Can Mynewt OS and BLE stack be run without the most highest priority interrupt?

Hi,

I’m working on a personal project and need some help from the community, since I just start to know Mynewt recently and not familiar with it.

The project is about wireless SIM interface, this is a quite new concept, let’s give more words here.  Each mobile phone has an IC card called SIM card from network provider to access the mobile network, the most important functionality of SIM card is network access authentication of mobile phone. The current SIM-phone interface is UICC-terminal interface with contactor, this wired-connection protocol is defined by ISO/IEC-7816, ETSI TS 102 221, etc. The basic idea of wireless SIM is to insert a wireless link between phone and SIM card, thus mobile phone can get network access authentication wirelessly without a SIM card inside its card slot, the SIM card is actually in (for example) a smart watch. This usage model give user the freedom to use different device (Phone, Pad, Watch) with the same one SIM card but no any plug-out and plug-in, and switch between the device seamlessly.

Currently the wireless SIM interface can be run with nRF51822 and nRF52832, I want the program can co-exist with Mynewt OS and BLE stack. The most challenge is that the program require the 2 most highest priority interrupt (at least 1 for nRF52832), I have tried to make it co-exist with Nordic’s soft-device BLE stack, but I have to disable the soft-device when the program events need high priority interrupt (since soft-device reserved the 2 highest priority interrupt), thus loss all the BLE connection. Although the soft-device can be re-started after the program events, but this is not an  idea solution since all the BLE stack will go through again. 

Is it possible to run Mynewt OS and BLE stack without the 1 or 2 most highest priority interrupt? if not, what is the potential issues?

Thanks a lot,

Jiacheng


Re: Can Mynewt OS and BLE stack be run without the most highest priority interrupt?

Posted by WangJiacheng <ji...@icloud.com>.
Hi, Will,

Thanks for your help,

The reason of nRF require high priority interrupts is that, from the point of view of phone side, the nRF is a proxy of SIM card, it should be always ready to receive phone command (UICC-terminal interface command). The arriving time of this phone command can not be predicted since mobile network is also involved  in the authentication process (and I also can not control the baseband chip of mobile phone). Moreover, if this command is not responded in time, the phone will treat the (proxy) SIM card as a bad card and stop power supply (nRF need this power supply to power on). I use nRF GPIOTE to sense this phone command arriving event and give the highest priority to ensure the command is responded in time.

Yes, nRF51 have not enough resource to run both my program and BLE stack, I will focus on nRF52.

The high priority  interrupt time of the program need at least 1ms ~ 2ms to read the 5-byte phone command, after this command read process, some BLE events can be inserted between the conversation of  phone and SIM card. However, each talk of phone or SIM card can not be interrupted, this talk may be up to 100ms. I’m trying to make the BLE connections is not dropped during this phone-SIM conversation.

I’ll try more with you help information.

Best Regards,

Jiacheng


> 在 2016年11月8日,13:18,will sanfilippo <wi...@runtime.io> 写道:
> 
> Hello:
> 
> Yes, you can adjust interrupt priorities. With the develop branch of mynewt you can adjust the priority for any interrupt.
> 
> By default, the radio uses the highest priority interrupt (0) for both the nrf51 and nrf52. If you need the two highest priority interrupts you can do that; you would change the radio priority to 2 and use priorities 0 and 1 for your other interrupts. Note that the nrf51 only has 4 interrupt priorities so you are somewhat limited there. The nrf52 has 8 I believe.
> 
> In the hal there is function called hal_bsp_get_nvic_priority(). By default, all interrupt priorities are assigned the lowest priority. With hal_bsp_get_nvic_priority() you can do some cool things:
> 
> 1) By adding a case to the switch statement, you can alter the priority that is being set for the interrupt when NVIC_SetPriority() is called.
> 2) You can “see” the priority for the other interrupts that are being set. All calls to NVIC_SetPriority() call hal_bsp_get_nvic_priority() so you can always know if some code is trying to set a priority.
> 
> If no call to NVIC_SetPriority() is being made for an interrupt, that interrupt will be at the lowest priority. Depending on the interrupt you want to make highest, you might have to add a call to NVIC_SetPriority().
> 
> What interrupt(s) did you want to make the high priority interrupts? Just curious…
> 
> As to potential issues: well, this is where things get tricky. If you are not running the radio at the highest priority it is possible that the BLE stack could be adversely affected. You could miss packets or drop connections; it depends on quite a number of factors. The BLE timing is quite tight, so if you are getting interrupted frequently and/or the interrupts take a long time, you could have issues.
> 
> Hope this helps...
> 
> 
>> On Nov 7, 2016, at 8:19 PM, WangJiacheng <ji...@icloud.com> wrote:
>> 
>> Hi,
>> 
>> I’m working on a personal project and need some help from the community, since I just start to know Mynewt recently and not familiar with it.
>> 
>> The project is about wireless SIM interface, this is a quite new concept, let’s give more words here.  Each mobile phone has an IC card called SIM card from network provider to access the mobile network, the most important functionality of SIM card is network access authentication of mobile phone. The current SIM-phone interface is UICC-terminal interface with contactor, this wired-connection protocol is defined by ISO/IEC-7816, ETSI TS 102 221, etc. The basic idea of wireless SIM is to insert a wireless link between phone and SIM card, thus mobile phone can get network access authentication wirelessly without a SIM card inside its card slot, the SIM card is actually in (for example) a smart watch. This usage model give user the freedom to use different device (Phone, Pad, Watch) with the same one SIM card but no any plug-out and plug-in, and switch between the device seamlessly.
>> 
>> Currently the wireless SIM interface can be run with nRF51822 and nRF52832, I want the program can co-exist with Mynewt OS and BLE stack. The most challenge is that the program require the 2 most highest priority interrupt (at least 1 for nRF52832), I have tried to make it co-exist with Nordic’s soft-device BLE stack, but I have to disable the soft-device when the program events need high priority interrupt (since soft-device reserved the 2 highest priority interrupt), thus loss all the BLE connection. Although the soft-device can be re-started after the program events, but this is not an  idea solution since all the BLE stack will go through again. 
>> 
>> Is it possible to run Mynewt OS and BLE stack without the 1 or 2 most highest priority interrupt? if not, what is the potential issues?
>> 
>> Thanks a lot,
>> 
>> Jiacheng
>> 
> 


Re: Can Mynewt OS and BLE stack be run without the most highest priority interrupt?

Posted by will sanfilippo <wi...@runtime.io>.
Hello:

Yes, you can adjust interrupt priorities. With the develop branch of mynewt you can adjust the priority for any interrupt.

By default, the radio uses the highest priority interrupt (0) for both the nrf51 and nrf52. If you need the two highest priority interrupts you can do that; you would change the radio priority to 2 and use priorities 0 and 1 for your other interrupts. Note that the nrf51 only has 4 interrupt priorities so you are somewhat limited there. The nrf52 has 8 I believe.

In the hal there is function called hal_bsp_get_nvic_priority(). By default, all interrupt priorities are assigned the lowest priority. With hal_bsp_get_nvic_priority() you can do some cool things:

1) By adding a case to the switch statement, you can alter the priority that is being set for the interrupt when NVIC_SetPriority() is called.
2) You can “see” the priority for the other interrupts that are being set. All calls to NVIC_SetPriority() call hal_bsp_get_nvic_priority() so you can always know if some code is trying to set a priority.

If no call to NVIC_SetPriority() is being made for an interrupt, that interrupt will be at the lowest priority. Depending on the interrupt you want to make highest, you might have to add a call to NVIC_SetPriority().

What interrupt(s) did you want to make the high priority interrupts? Just curious…

As to potential issues: well, this is where things get tricky. If you are not running the radio at the highest priority it is possible that the BLE stack could be adversely affected. You could miss packets or drop connections; it depends on quite a number of factors. The BLE timing is quite tight, so if you are getting interrupted frequently and/or the interrupts take a long time, you could have issues.

Hope this helps...


> On Nov 7, 2016, at 8:19 PM, WangJiacheng <ji...@icloud.com> wrote:
> 
> Hi,
> 
> I’m working on a personal project and need some help from the community, since I just start to know Mynewt recently and not familiar with it.
> 
> The project is about wireless SIM interface, this is a quite new concept, let’s give more words here.  Each mobile phone has an IC card called SIM card from network provider to access the mobile network, the most important functionality of SIM card is network access authentication of mobile phone. The current SIM-phone interface is UICC-terminal interface with contactor, this wired-connection protocol is defined by ISO/IEC-7816, ETSI TS 102 221, etc. The basic idea of wireless SIM is to insert a wireless link between phone and SIM card, thus mobile phone can get network access authentication wirelessly without a SIM card inside its card slot, the SIM card is actually in (for example) a smart watch. This usage model give user the freedom to use different device (Phone, Pad, Watch) with the same one SIM card but no any plug-out and plug-in, and switch between the device seamlessly.
> 
> Currently the wireless SIM interface can be run with nRF51822 and nRF52832, I want the program can co-exist with Mynewt OS and BLE stack. The most challenge is that the program require the 2 most highest priority interrupt (at least 1 for nRF52832), I have tried to make it co-exist with Nordic’s soft-device BLE stack, but I have to disable the soft-device when the program events need high priority interrupt (since soft-device reserved the 2 highest priority interrupt), thus loss all the BLE connection. Although the soft-device can be re-started after the program events, but this is not an  idea solution since all the BLE stack will go through again. 
> 
> Is it possible to run Mynewt OS and BLE stack without the 1 or 2 most highest priority interrupt? if not, what is the potential issues?
> 
> Thanks a lot,
> 
> Jiacheng
>