我们有一个在Pan1740模块上运行的应用程序。我们在DA14580上处理大多数邮件,但我们确实在SPI上有一个外部接口到MCU。通信使用GTL(即GTL接口与集成处理器应用程序“)。
We are now trying to make our working app run with extended sleep enabled. We have the right things defines I believe...
#define CFG_GTL_SPI
#define CFG_APP
#define cfg_integrated_host_gtl.
#define cfg_mem_map_ext_sleep.
#undef cfg_mem_map_deep_sleep.
#undef cfg_development_debug.
const static sleep_state_t app_default_sleep_mode = ARCH_EXT_SLEEP_ON;
We have callbacks set up on .app_going_to_sleep and .app_resume_from_sleep to toggle a GPIO line on and off to indicate sleep, but we see no such changes.
Part of the problem is that we cannot debug the main loop to understand why it does not sleep as we need to turn debugging off.
If we leave CFG_DEVELOPMENT_DEBUG #defined and debug the main loop we *think* we see it failing to enter sleep at rwip_prevent_sleep_get().
我们怀疑这是the presence of the GTL. Is this possible? How can we get sleep mode to work?
谢谢,
Paul.
嗨pvmellor,
You will have to choose if your device will work using GTL (using external processor) or it will have an application level module (APP_TASK enabled, standalone configuration). You wont be able to have both, this is what the CFG_APP definition dictates. If the CFG_APP is defined then you will be in integrated processor mode if it is undefined then you will be in external mode.
Thanks MT_dialog
**COULD YOU PLEASE PRIORITISE THIS THREAD**
Better still - could we take the discussion off line as a support ticket or and have a call/skype to discuss?
我们已完成硬件设计和构建,并非常接近完成我们的固件开发。您的回复似乎表明我们有一个阻塞问题,这可能需要我们交换给不同的BLE提供商/解决方案。因此,我们需要尽快解决这个问题。
We are currently using an architecture very similar to the diagram attached (jpg in zip) as shown in UM-B-017, which is entitled "DA14580/581 GTL interface in integrated processor applications". We have an integrated processor application (i.e. a "task app") and also a GTL interface, as the document describes.
The only differences are that we use SPI for external communications, not UART, and we do not use the explicit Wakeup GPIO (we use DREADY for this purpose).
Could you confirm: are you saying as in your previous reply that is it not possible to use the GTL interface in an integrated processor application? That the architecture above is not supported? Or perhaps we have misunderstood this document and its meaning?
We use the transport format as described in that document section 5, we define our own set of application level messages and handlers in app.h as defined in section 6. Section 7 discusses the max sleep period while GTL is in use, but we have not yet got to this point. Our code is stable and has been running well for some time passing GTL messages to our external MCU. However, our application will not go into (extended) sleep.
如果支持附加图中的架构,请您可以帮助我们了解我们所需要的更改需要更改以进行更改吗?我们需要一个task_app(如图所示)来处理配置文件相关的消息交换(Create_DB,启用/禁用,写入指示等),以及GTL接口,以在较少频繁的基础上使用外部处理器交换高级消息发生特定的应用程序级事件。我们还支持播放和低音配置文件(并且可以在未来添加其他人)。
我们发现CFG_APP围绕混淆的文档。config_basic.h文件中的注释说
/***************************************************************************************************************/
/* Integrated or external processor configuration */
/* -defined Integrated processor mode. Host application runs in DA14580 processor. Host application */
/* is the TASK_APP kernel task. */
/ * - 义外部处理器模式。主机应用程序在外部处理器上运行。与* /沟通沟通
/* BLE application through GTL protocol over a signalling iface (UART, SPi etc) */
/***************************************************************************************************************/
Yet in the document mentioned above it says:
"If undefined, it will enable the communication over GTL/UART interface of application task in *integrated processor application* with an external processor."
您的迅速答复将最受欢迎。
Paul.
嗨pvmellor,
Normally how the SDK does things is to push either to the TASK_GTL or to the TASK_APP, we dont have any project that uses both, the SDK reports in one application task, i had a look in the code and apparently it might be plausible to have both (never tested in the actual field and what i am mentioning is just a theory). So if what you are doing is working i would suppose that you have the CFG_APP defined so every message from the stack towards the application it would end up to TASK_APP, so in order to get some of those messages to the GTL task i assume that you are pushing the messages from the TASK_APP back to the stack and have the TASK_GTL as a receiver, so is that what you are doing in your project, since this is the only way i assume that this would work ?
Regarding the sleeping, yes GTL is possible to affect the sleeping of the device, if the transmittion of the device hasn't ended and there are still pending data that need to be sent out then the device will stay awake until they do. Regarding the debugging and sleeping, if you are using the latest SDK this should be possible to do.
Thanks MT_dialog
Thanks for the response. You are right in your assumptions about how TASK_APP and TASK_GTL are working for us, except that the messages we send to TASK_GTL are not the same ones we receive as TASK_APP: they are higher level application-specific messages that we define ourselves. Similar to those described in UM-B-017 and using the method set out there. For example: for the MCU to initialise the bonding database (which is stored by the external MCU), to start/stop different types of advertising, to put the current battery voltage level (again this is sensed by the MCU), and for the DA14580 to send firmware update packets to the MCU for over-the-air firmware update, and so on.
There are no GTL messages pending or in transmission when we attempt to sleep. GTL messages are not sent particularly often - generally just at start up time and when there is a connection in progress and the end use is doing a data sync or firmware update.
Most of the time the device is not in a connected state, and is not advertising either. It will simply be asleep waiting for a wake up signal from the MCU (the device is motion sensitive and wakes on motion). At other times it is advertising and sleep is again required to conserve power.
Note we are working on the PAN1740ETU evaluation module with Segger J-Link debugger for testing, and on our own boards.
我们在广告时每376毫秒查看App_on_ble_powered()和app_on_system_powered()调用的调用,每376ms连接。
Some specific questions then:
1) If our scenario/architecture is rare and untested, how come there is a document UM-B-017, which is entitled "DA14580/581 GTL interface in integrated processor applications" that specifically describes it? Have we misunderstood this document? It seems to represent exactly this architecture and describes how to use it.
2) Since there is no GTL activity in place or pending, could you help us to understand what could be preventing the device from sleeping? This is the most important question for us to answer right now. What do we need to test? What can we do?
3) If we leave CFG_DEVELOPMENT_DEBUG #defined and debug the main loop we think we see it failing to enter sleep at rwip_prevent_sleep_get(). Could you explain this? Could it be related to the GTL? It is deep in the SDK implementation and difficult for us to debug.
4)我们使用的是SDK 5.0.4 - 这是可以留下开发调试的吗?
谢谢,
Paul
嗨pvmellor,
1)您所指的文档位于与SDK3相关的支持站点的已停止文档中,显然这种架构在移动到较新的SDK时被贬低(据我所知,它没有使用)但是,函数仍然是新的SDK,据我所知,我可以告诉你没有误解这些文件,显然你也可以在SDK 5上有这种配置,但对此误解和我的仓促答案道歉。
2-3)CFG_DEVELIMMENT_DEBUG定义所做的一切都是在运行FW运行时删除任何断言,并且在深度睡眠的情况下,它将关闭整个SYSRAM,我没有在睡眠之间找到任何关系和该国旗之间的任何关系。你能告诉我你究竟确定设备睡眠的究竟是多么确定?我的意思是你通过电力分布器测量这一点,或者您通过DMM测量?RWIP_Prevent_sleep_get()应在休息中恢复与RW堆栈或GTL接口相关的东西进行打破,但我仍然没有看到任何关系,并且您看到了CFG_development_debug(您是否看到行为的任何变化在睡眠和cfg_development_debug之间)。一个想法要检查这一点是在函数底部的RWIP_SLEEP()函数中放置一个刹车点,在该函数底部决定在检查正确的条件后确实可以睡眠,如果您打击该断点然后该设备将睡觉。
4) SDK5.0.4 is the only SDK that is able to operate with the debug on and while in sleep mode.
Thanks MT_dialog
根据您的建议,我已经将CFG_Development_debug放在上面并调试睡眠代码/问题。
1) To detect sleep I was using the callbacks set up on .app_going_to_sleep and .app_resume_from_sleep to toggle a GPIO line on and off to indicate sleep. Closer inspection showed that these functions where optimised out by the compiler. It seems that the peripherals are switched off by the time these functions are called, so the code was removed by the compiler (surprising). I moved the code to toggle the GPIO lines to just before the peripherals are disabled and this method worked to indicate sleep.
2) There are three places in rwip_sleep() that were preventing it from sleeping.
rwip_prevent_sleep_get)测试()
b)通过(ble_intrawstat_get()和ble_grosstgtimintrawstat_bit的内核定时器测试
c) Same as above - but a second test of the kernel timers.
With these three tests commented out, the device DID go into extended sleep. I have nice traces of it sleeping and waking for advertising at 376ms, and when I connect I see it sleeping and waking at 48ms for connection events. If I turn advertising off, then it will sleep and wake as per the CFG_MAX_SLEEP_DURATION_PERIODIC_WAKEUP_MS timer. I currently have this set up to 600,000 (ten minutes) and working fine (original value was 500 for 0.5 seconds).
3)在每个唤醒/睡眠期间,再次启用GTL接口。但有一个问题。每次发送两个流字节,然后在设备再次休眠时,然后流关闭。这会导致MCU上的GTL协议代码出现问题 -您是否能够了解这是否可以修复?See attached diagram. I suspect it is due to flow_on being called directly via the jump_table, and then perhaps being called again as part of gtl_exit_sleep(); However, I cannot debug back past the jump table.你能解释这里正在发生的事情,谁叫这些跳跃表函数以及如何调试它们?. Also I do not have any code for gtl.c. Is this available?
4) If I put the restore rwip.c back to its original state, then as stated above there is no sleep. However, after the first GTL message is sent, then sleep start working normally. So I think there must be an issue with the GTL being considered to be in the wrong state initially. Perhaps this is related to the flow_on issue above.could you have a look and see if this could be improved, or worked around?
谢谢,
Paul
嗨pvmellor,
2-3)RWIP_SLEEP()拥有上述所有检查,以了解上述内容的任何内容是否具有挂起的过程,如果它不会睡觉,请评论这些条件不会明智或推荐,因为设备将如果有什么可做的事情,无论如何都要睡觉。为了让设备睡眠,通过这些检查并决定。您是否看到设备始终会破坏,从未达到程序核心深度睡眠,这将发出睡眠期的乞讨?如果您提到由于内核定时器导致设备取消睡眠,如果您从项目中删除定时器(如果您使用的是任何),请查看会发生什么(如果是用于测试)?还可以请删除GTL并检查设备是否存在相同的行为?只需尝试将应用程序用作独立设备,并验证设备进入睡眠模式。然后,您可以重新应用GTL配置并检查GTL是否导致睡眠问题。尝试查看外部主机的任何挂起命令或接口中的信号,使设备唤醒。
我能够使用BLE_APP_PERITIELAL示例并在该项目上应用SPI GTL配置,然后我使用了Proximity Reporter主机项目(另一个580上的Host_proxr项目),以充分嵌入式/ GTL修改项目充当主机,我可以在外部主机的应用程序中找到睡眠中的任何问题(在编写自定义特征时从Task_App从Task_App从Task_App发送GTL消息)。
4) Regarding the problem that you are reporting, this is a known issue with the GTL over SPI and yes it sends a duplicate flow on transmit when the device is waking up, and as far as i am aware there is going to be no action to fix the issue (checking on that to be sure), what you can try as a work around would be to add a counter in order not issue a flow on byte more times than they are neccessary, like below:
Apply the following in the spi_hci_flow_off_func()
if( 0 == flow_on_cnt)
{
return true;
}else
{
flow_on_cnt--;
}
Apply the following in the spi_hci_flow_on_func()
if(flow_on_cnt> 0)
{
return;
}别的{
flow_on_cnt + +;
}
This is not a verified or tested solution, but its something you can try in order not have two flow on signals.
Thanks MT_dialog
Thanks for the fix for the dual flow-on problem. This has solved one of my problems.
The other problem remains. Let me summarise:
We use GTL and an integrated processor (TASK_APP). TASK_APP sends messages to the external processor via GTL to perform high-level application specific tasks.
我们已扩展睡眠配置。
When we start up the DA does not sleep. It will advertise and connect and function properly, but it does not sleep.
If we connect to it from a mobile device, and write to a characteristic (control point) that results in a GTL message being sent by the DA to the MCU host, then immediately after this GTL message has been sent the DA starts to sleep as it should. We see it wake for each connection event. If we disconnect our mobile we see it wake for each advertise event. It works as we would expect, sleeping in between events. We can even put it so sleep with no advertising and wake it via an external wakeup event on a GPIO pin.
So we believe this problem is due to the GTL message and the GTL state. We do not explicitly use any kernel timers.
After debugging we see two reasons it will not sleep, in rwip.c.
if (rwip_prevent_sleep_get() != 0)
break;
This line prevents it getting further (i.e. the break is executed). This is because rwip_prevent_sleep_get() is returning RW_GTL_TIMEOUT. So we use
rwip_prevent_sleep_clear(RW_GTL_TIMEOUT);
in our initialisation code and this line no longer prevents us sleeping.
The second problem is with
if (ble_intrawstat_get() & BLE_GROSSTGTIMINTRAWSTAT_BIT)
break;
BLE_GROSSTGTIMINTRAWSTAT_BIT位设置并防止睡眠。我们没有多少数据关于该位,并且在代码中没有明确设置任何地方。我们尝试过
REG_BLE_WR(BLE_INTRAWSTAT_ADDR, BLE_INTRAWSTAT_RESET);
在我们的初始化代码中,但这并没有帮助 - 它正在其他地方设置。
Could you help with more information about this bit and what it is doing and how it is set and how it may be related to the GTL interface. Or - better still - can you suggest a fix as you did for the previous problem?
谢谢,
Paul.
对话框 - 上述问题的任何帮助?
It is holding up our development and we do not have a lot of time left!
Many thanks,
Paul.
嗨pvmellor,
您提到设备停止的部分用于检查设置的定时器,如果有时间即将到期的计时器,则设备将取消休眠过程。由于设备在GTL图层上交换时,设备会睡眠,因此您是否尝试在设备和主机之间交换伪消息,并检查它是否会强制设备睡觉?
Thanks MT_dialog
是的 - 这就是我们现在的工作方式。我们通过移动设备连接到设备,然后手动导致要发送的虚拟消息。然后,这将开始睡觉的设备。
Paul
嗨pvmellor,
我的意思是,只要我能理解来回m the description above, for some reason that i am not able to determine since i am not able to replicate on my setup, the device stays active and apparently after you send or receive a GTL message the device operates as it should. So what i am suggesting is to test that case when the device is not connected, for example send a dummy GTL message to the external MCU as soon as the device gets configured or as soon as the device creates its database. Also is there any external wake up configuration on the device, if yes, can you please remove the functionallity and check if that creates the sideeffects that you are experiencing ?
Thanks MT_dialog
After experimenting with your suggestions we found a solution. We were sending an initial READY message to the MCU, and receiving back an INIT message. However, we sent the READY message during user_app_init() and this caused the problem. If we did not send the READY message at all then the DA went into sleep straight away (after the 2 sec delay) as we expected. If we send the READY message during user_app_on_db_init_complete() then sleep still worked as expected. So by delaying the READY message the problem seems to be solved.
谢谢,
Paul
嗨pvmellor,
Thanks for letting us know, glad you figure this out.
Thanks MT_dialog