Dear Dialog,
I'm trying to put our application (DA14680-01, SDK 1.0.8.1050.1) to extended sleep. For this I took the extended_sleep demo app and ported it to our board (that has LEDs on LED pads, not GPIOs, so I put them on TIMER2/PWM). We're going to use UARTs, so I tried to print debug messages on UART2 from vTimerCallback() and put a call to hw_uart_reinit() in periph_init(). (For the output, I defined CONFIG_CUSTOM_PRINT and wrote a _write() function calling hw_uart_wrute_buffer(); I also tried to use ad_uart). I also added pm_set_wakeup_mode(true) to wait for XTAL16M to settle. The board has external 32.768kHz and 16MHz crystals.
However, the board behaviour changes, depending on how it was reset. If it was reset from JLink (by reboot_device.sh or by "monitor reset" from gdb), XTAL16M is running all the time (we checked with an oscilloscope), the LEDs stay on and UART output works.
But if it's reset either from firmware, or using the reset button, or by taking the battery out and putting it back in, XTAL16M stops and the LEDs go off during sleep; the LEDs still work when the board is awake. And if I try to use the UART after waking up, the CPU hangs and XTAL16M keeps running.
I'll appreciate if you can tell us how to use UARTs with extended sleep. The situation is a bit hard to debug, as I haven't found a way to attach the debugger without resetting the SoC.
Below are our periph_init() and write() functions.
Many thanks for your attention,
Vadim, MatchX.
静态孔隙periph_init (void)
{
/*
* Set-up Peripheral GPIOs
*/
hw_uart_reinit(HW_UART2, &uart_cfg);
hw_gpio_set_pin_function(HW_GPIO_PORT_4, HW_GPIO_PIN_5, HW_GPIO_MODE_OUTPUT,
HW_GPIO_FUNC_UART2_TX);
hw_gpio_set_pin_function(HW_GPIO_PORT_4, HW_GPIO_PIN_4, HW_GPIO_MODE_OUTPUT,
HW_GPIO_FUNC_UART2_RX);
/*
* Power up peripherals
*/
/*
* GPIO initializations
*/
/* Configure GPIO for LED output. */
timer2_config t2cfg = {
.pwm3_start = 0,
.pwm3_end = 0xffff,
.pwm4_start = 0,
.pwm4_end = 0xffff,
};
hw_timer2_init(&t2cfg);
hw_timer2_enable();
hw_led_set_led2_src(HW_LED_SRC2_PWM3);
hw_led_set_led3_src(HW_LED_SRC3_PWM4);
hw_led_enable_led2( ulLEDState & 1UL );
/* Configure GPIO for button. */
hw_gpio_set_pin_function(HW_GPIO_PORT_3, HW_GPIO_PIN_3, HW_GPIO_MODE_INPUT, HW_GPIO_FUNC_GPIO);
//printf("init\r\n");
}
int _write(int fd, char *ptr, int len)
{
hw_uart_write_buffer(HW_UART2, ptr, len);
return len;
}
Hi matchx,
Regarding the fact that you still see the XTAL16 running if you reset it via the Jlink, that is because of the Jlink itself, as long as you have the JTAG attached on the 68x board the device wont shut down the power domain and the XTAL16 will continue operating, even if you have declared that the device will go in sleep. Regarding how to used the UART, the adapters are introduced in that case instead of the directly using the low level drivers. So please have a look at the UM-B-044-DA1468x Software Platform Reference.pdf in paragraph 8 which explains the architecture of the sleeping and how the adapters are used while sleeping, also please have a look at paragraph 11 Drivers and Adapters, which explians the adapter scheme in more detail and there you can also find an example on how to use the UART.
Thanks MT_dialog
Hi MT, thanks for your reply.
I have tried ad_uart, as I noted above.
I investigated some more and was surprised to find out that it's printf() that kills the system, but only after wake-up. Even more surprising is that snprintf() + write() work perfectly well.
(I'm using Embedded ARM toolchain 5_4-2017q1 which I compiled myself, the reason being that Dialog's binaries don't run on Archlinux due to libncurses version conflict.)
Thanks for the help,
Vadim, MatchX.