⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads athttps://www.dialog-seminile.com/support.。我们将在未来几天修复错误/优化搜索和标记。
11个帖子/ 0新
最后一篇
Chris0409.
Offline
最后一次露面:3年10个月前
加入:2017-01-11 05:59
app_easy_timer错误

Hi, everyboady,
I have used the app_easy timer to do a Led blink function. but the device reboot continuous after I flashed the code to spi flash. I debuged the code and see that porgram goes into the blink function and the invoked app_easy_timer function.
the program never goes forward to code ( req->delay=delay; req->timer_id=timer_id; ke_msg_send(req);)
突出代码后(struct create_new_timer_struct * req = ke_msg_alloc(app_create_new_timer,task_app,task_app,create_new_timer_struct);

is it mean that memory alloc error,and is the reboot caued by this reason? I never encountered this phenomenon ever before

设备:
wi_dialog.
Offline
最后一次露面:1 day 15 hours ago
职员
加入:2014-01-03 16:21
Hi,

Hi,
您是否尝试使用SDK5中的App_easy_Timer功能运行“Prox_Reporter”参考软件?您所描述的观察不能得出结论问题是由于“app_easy_timer”功能。需要更多信息,例如如何运行测试,在软件上,....
Regards,

Chris0409.
Offline
最后一次露面:3年10个月前
加入:2017-01-11 05:59
Hi, Wl_Dialog,

Hi, Wl_Dialog,
我知道app_easy_timer是问题,因为在我添加LED眨眼代码之前,我还有一个使用应用程序易于计时器的进程的DSPS主机项目,它可以正常工作。
我想知道的是,我只是用一个应用程序易于计时器来切换LED引脚,为什么我在代码处块
struct create_new_timer_struct * req = ke_msg_alloc(app_create_new_timer,task_app,task_app,create_new_timer_struct);
遵循是LED.c的源代码

#include "led.h"
#include "app_easy_timer.h"

/ * LED控制结构* /
typedef struct {
uint8_t todo;/ *闪烁循环留下* /
uint8_t percent; /* On cycle percentage */
uint16_t period; /* On/off cycle time (msec) */
UINT32_T接下来;/ *下次更改的时间* /
}LedControl_t;

/ ***************************************************************************************************
*GLOBAL VARIABLES
***************************************************************************************************/

静态LEDCONTROL_T LEDCTRL __ATtribute __((部分(“保留_mem_area0”),ZERO_INIT));

/ ***************************************************************************************************
*LOCAL FUNCTION
***************************************************************************************************/
静止voidedupdate(空白);

/ ***************************************************************************************************
*FUNCTIONS - API
***************************************************************************************************/

/ ***************************************************************************************************
*@fn LedInit
*
* @brief初始化LED服务
*
* @param init - 指向包含初始化值的void
*
*@return None
***************************************************************************************************/
void LedInit (void)
{
LED_INIT();
}

/ ***************************************************************************************************
*@fn LedBlink
*
* @brief闪烁LED
*
*@param leds - bit mask value of leds to be blinked
* numblinks - 闪烁的数量
*百分比 - LED的每个时期的百分比
*will be on
*周期 - 每个周期的长度为毫秒
*
*@return None
***************************************************************************************************/
void legblink(UInt8_t numblinks,uint8_t%,uint16_t句号)
{
ledCtrl.todo = 2*numBlinks-1;
LEDCTRL.percent =百分比;
ledCtrl.period = period;
LED_OFF();
if(百分比&&期)
{
if(百分比<100)
{
app_easy_timer(1,LedUpdate);
}
else
{
带领();
}
}
else
{
//turn off
LED_OFF();
}
}

/ ***************************************************************************************************
* @fn ledupdate.
*
*@brief Update leds to work with blink
*
* @param none
*
*@return none
***************************************************************************************************/
静止voidedupdate(空白)
{
LED_Toggle();
ledCtrl.todo--;
if(ledctrl.todo / * || LED_STATE()* /)
{
if(LED_STATE())
{
ledCtrl.next = ledCtrl.period*(100-ledCtrl.percent);
}
else
{
LEDCTRL.NEXT = LEDCTRL.PERIOD * LEDCTRL.PERCENT;
}
app_easy_timer(ledCtrl.next/10,LedUpdate);
}
}
Can you help me to check if there is some error of the code, I really can't find the reason.
other more, I just used LedInit to initi the LED port and LedBlink(20,35,1000) to do the test in System_Init() .

Chris0409.
Offline
最后一次露面:3年10个月前
加入:2017-01-11 05:59
a little more, I found that

一点稍微,我发现我在system_init中调用ledblink(),我将在闪存到闪存后连续重启。但是,如果我在system_init()之后在main_func()中调用LeDblink(),那么这种现象不会发生,但我从来没有能够调用Ledupdate()。此外,当按下按钮时,我也开始了一个计时器,我可以在计时器过期时收到调用此计时器的回调。这真的很困惑我,任何建议都会受到欣赏!

wi_dialog.
Offline
最后一次露面:1 day 15 hours ago
职员
加入:2014-01-03 16:21
Hi,

Hi,
Your issue is properly related to where you put your "LedBlink(20,35,1000)" statement. It is because app_easy_timer and malloc() require the kernel timer and heap service. Your function can only be called after the kernel is initialized and activated. It is suggested to put your statement after system_init() and make your LedBlink function blink forever to ease your debugging.

int main_func(void)
{
sleep_mode_t sleep_mode;

//全球初始化
system_init();

LEDBLINK(20,35,1000);

/*
************************************************************************************
*平台初始化
************************************************************************************
*/
while(1)
{
.....
}
}

Regards,

Chris0409.
Offline
最后一次露面:3年10个月前
加入:2017-01-11 05:59
我已经完成了你

我在建议时已经完成了,但我仍然无法让LED眨眼。现在我在设备连接事件上调用LeDBlink,LED闪烁右侧。所以它是因为睡眠是睡眠,这样我们无法启动计时器?

wi_dialog.
Offline
最后一次露面:1 day 15 hours ago
职员
加入:2014-01-03 16:21
Hi,

Hi,

在进入睡眠模式之前,它被认为没有更多的活动,包括LED闪烁。无论在扩展或深度睡眠模式下,所有I / O块都将关闭,包括定时器服务。因此,禁用LED闪烁定时器服务。

为了缓解新驱动程序或功能的调试,简单的方法是将一个语句添加如下以禁用进入睡眠模式但空闲模式,以给出对软件行为的最小影响。

//获取允许的睡眠模式
// time from rwip_power_down() to WFI() must be kept as short as possible!!
sleep_mode = rwip_power_down();
/ *声明添加* /sleep_mode = mode_idle;

Then you should see your LED blink continuously.

Regards,

wi_dialog.
Offline
最后一次露面:1 day 15 hours ago
职员
加入:2014-01-03 16:21
Hi,

Hi,

Fixed the mistake as follows:
//获取允许的睡眠模式
// time from rwip_power_down() to WFI() must be kept as short as possible!!
sleep_mode = rwip_power_down();
/ *声明添加* /
if ((sleep_mode == mode_ext_sleep) || (sleep_mode == mode_deep_sleep))
{
sleep_mode = mode_idle;
}

Regards,

Chris0409.
Offline
最后一次露面:3年10个月前
加入:2017-01-11 05:59
What confused me is that:

What confused me is that:
I invoke the LedBlink() after system_init(),at when the timer kernal has going up,. and in the LedBlink(), I has setup a timer which will wakeup the BLE, so why my timer callback still can't get triggled? if the BLE is sleep when I first create the timer in LedBlink(), if this is true? I think I can force ble wakeup before I create the timer for the first time. I have tried the API arch_ble_force_wakeup() 、arch_ble_ext_wakeup_on() etc. but still cant blink.Does these api can really force the device wakeup?

wi_dialog.
Offline
最后一次露面:1 day 15 hours ago
职员
加入:2014-01-03 16:21
Hi,

Hi,
可以通过简单地迫使leep_mode进入mode_ext_sleep或mode_deep_sleep来完成验证您的LEDBLink()函数及其行为的技术。要集成LED闪烁功能,并让它在您预期的行为中表现,您需要了解软件的结构。
In real application, there is two (2) threads running independently, BLE stack and User application. Kernel provides only the services and user application requires to manages and supervise all resources usage and monitor all activities to determine the device can go into sleep mode or not.

int main_func(void)
{
sleep_mode_t sleep_mode;

//全球初始化
system_init();

/*
************************************************************************************
*平台初始化
************************************************************************************
*/
while(1)
{
做 {
//安排所有待处理的事件
schedule_hile_ble_on();
}
while(app_asynch_proc()!= goto_sleep);//授予控件到应用程序,尝试掉电
//如果应用程序返回goto_sleep
.....
}
}

app_asynch_proc()函数是一个检查的用户application whether any activity is on-going that prevents the device goes into sleep mode while BLE stack thread is ready to go into sleep.

typedef enum {
GOTO_SLEEP = 0,
KEEP_POWERED
} arch_main_loop_callback_ret_t;

In your case, this function can return "KEEP_POWERED" as long as LED is blinking not allowing the device into sleep.

static inline void schedule_while_ble_on(void)
{
// BLE时钟已启用
while(ble_is_powered())
{
//设置了BLE事件结束。条件RF校准可以运行。
UINT8_T BLE_EVT_END_SET = KE_EVENT_GET(KE_EVENT_BLE_EVT_END);

//execute messages and events
rwip_schedule();

if (ble_evt_end_set)
{
uint32_t sleep_duration = 0;
rcx20_read_freq();

//if you have enough time run a temperature calibration of the radio
if (lld_sleep_check(&sleep_duration, 4)) //6 slots -> 3.750 ms
// check time and temperature to run radio calibrations.
conditionally_run_radio_cals();
}

//授予对申请的控制,尝试睡觉
//如果应用程序返回goto_sleep
if (app_asynch_trm() != GOTO_SLEEP)
{
继续;// rwip_schedule()再次调用
}
else
{
arch_printf_process();
休息;
}
}
}

The app_asynch_trm() function handles user application while BLE stack is running. The rwip_schedule() will process all messages in the queue till completion and the control will pass to app_asynch_trm() function and based on the returned value "KEEP_POWERED" or "GOTO_SLEEP" to decide to keep alive or go to sleep accordingly.

请注意,没有功能可以跟踪任何软件计时器运行。软计时器的所有者的责任是跟踪其活动。

To develop your application in SDK5, it is recommended to study the following structure and understand how it works as it is the key of the SDK5 structure.

struct arch_main_loop_callbacks {
void(* app_on_init)(空白);
arch_main_loop_callback_ret_t (*app_on_ble_powered)(void);
arch_main_loop_callback_ret_t (*app_on_system_powered)(void);
void (*app_before_sleep)(void);
sleep_mode_t(* app_validate_sleep)(sleep_mode_t sleep_mode);
void (*app_going_to_sleep)(sleep_mode_t sleep_mode);
void (*app_resume_from_sleep)(void);
};

static const struct arch_main_loop_callbacks user_app_main_loop_callbacks = {
。app_on_init = default_app_on_init,

/ /默认情况下看门狗定时器重载和resumed when the system wakes up.
// The user has to take into account the watchdog timer handling (keep it running,
// freeze it, reload it, resume it, etc), when the app_on_ble_powered() is being
// called and may potentially affect the main loop.
。app_on_ble_powered = NULL,

/ /默认情况下看门狗定时器重载和resumed when the system wakes up.
// The user has to take into account the watchdog timer handling (keep it running,
// freeze it, reload it, resume it, etc), when the app_on_system_powered() is being
// called and may potentially affect the main loop.
。app_on_system_powered = NULL,

。app_before_sleep = NULL,
.app_validate_sleep = null,
.app_ging_to_sleep = null,
.app_resume_from_sleep = null,
};

Regards,

Chris0409.
Offline
最后一次露面:3年10个月前
加入:2017-01-11 05:59
really thanks very much,

really thanks very much, useful suggestion