Hi,
我正在使用基本套件在DA14580 BLE上工作。
There are two LED connected on board. I blinked led using timer handler and control intensity using PWM.
After this I have modified code for sleep and wake from button (GPIO inerrupt) as per below link of forum that I posted.
https://support.dialog-semicondiondiondum/forums/post/dialog-smartbond-bl ...
After developing logic as per above sleep and wake is working fine, but after modified code for sleep and wake I am facing some below issue.
1. LED blinking hanlder is not working perfect that previously work fine, blinking has been doing random not as per set timer handler using "app_easy_timer" function.
2. I have control intensity using PWM, Now PWM behaviour is also random. sometimes it very bright and some times very low bright.
我叫做“app_easy_timer”函数在唤醒时创建Hanlder,并调用“app_easy_timer_cancel”函数,以在睡眠时取消处理程序。
please how can i solve above issue.
Thanks
Hi JBaczuk,
When you mentioned that you modified the code for sleep i suppose that you mean that you have enabled the sleep mode. Since you have enabled the sleep mode be aware that the device will shut down all the peripherals, timers, uarts, spi, etc in order to go to sleep, there is no check whatsoever that will keep the device awake if you have set a timer or toggling a LED etc. But be aware that the 580 will latch the GPIOs of the device when it goes to sleep mode, that means that it will retain the state of the pin to the state it was before going to sleep. So what you are seeing is that in every wake up (in order to advertise or keep a connection) all the peripherals are initialized and start operating and as soon as you go to sleep the PWM shuts down and the LED are kept in their state before sleep. So for the PWM in order to work properly you will have to keep the device awake, and regarding the LED you will have to keep the state of the pin in a custom variable in order to be reinitialized to that state when the device wakes up (the 580 will keep the state of the gpio while sleep but as soon as you wake up the periph_init function will run and the reinitialize the pins in their original state, so you will have to keep the state of the pin in a variable and upon wake up apply this value in the periph_init function).
谢谢mt_dialog.
MT_dialog,
Thanks for the reply. I'm sorry I will clarify my question. When I first power on the device, it is immediately put into deep sleep using:
ARCH_SET_DEEP_SLEEP();
arch_ble_ext_wakeup_on();
app_button_enable();
No LEDs, timers, or pwm have been used yet.
Then, when the button is pushed, we wake up the device using code from ble_app_sleepmode example:
static void app_button_enable(void)
{
app_easy_wakeup_set(app_wakeup_cb);
wkupct_register_callback(app_button_press_cb);
gpio_configurepin(gpio_button_port,gpio_button_pin,input_pullup,pid_gpio,false);
wkupct_enable_irq(wkupct_pin_select(gpio_button_port,gpio_button_pin),//选择pin(gpio_button_port,gpio_button_pin)
WKUPCT_PIN_POLARITY (GPIO_BUTTON_PORT GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
1, // 1 event
40); // debouncing time = 0
}
static void app_wakeup_cb(void)
{
if (ke_state_get(TASK_APP) == APP_CONNECTABLE)
{
user_app_adv_start();
led_mode mode = POWER_ON;
led_pattern(mode);
}
}
But, it appears something is interfering with the LEDs. We have 2 leds, both using timer2 and pwm2 (for 1 led) and pwm3 (for the other) and while they are cycling (on and off every second or so), something is shutting them off (about 3 times per second).
我想知道与睡眠模式有关的事情是否会影响定时器。当设备唤醒时,它们仅初始化,所以我不认为深睡眠会导致它忘记PWM或定时器(在设备唤醒之前没有启动)。
Hi JBaczuk,
As mentioned above, when the device is in sleep mode (waking up and falling to sleep in order to serve only BLE events) the 580 will shut down all of its peripherals. So in order to have the PWM and the timers working with no disruption from the waking up and the sleeping procedure you will have to disable sleep while the timers are operating (you can do this in run time via using the arch_disable_sleep()). This will keep the device awake and the timers that are working in PWM mode as well. After you 're done with that you can re-enable the sleep mode via the arch_set_deep_sleep() or arch_set_extended_sleep().
谢谢mt_dialog.