4 weeks ago
app_easy_timer not working on user_app_on_init
Posted bygustavo.laureano65 points 5 repliesHi,
I followed this guide:
http://lpccs-docs.dialog-semiconductor.com/Tutorial_SDK6/adv_data.html
to make the advertising data dynamic, but for some reason the timer is not started when called from user_app_on_init, but works when called from another place (like on_disconnect)
The function in being called inside app_on_init (checked with breakpoint) and it is not falling into the "return EASY_TIMER_INVALID_TIMER" (also checked with breakpoint)
Any ideas why would the timer not start from init?
Thanks
Best Regards
Gustavo
3 weeks ago
Hi PM_Dialog
Thanks, It works when I start from the adv_start user callback, the only change I made was to always cancel any previous timer, otherwise it was generating multiple timer instances running in parallel:
void user_app_adv_start(void) { app_easy_timer_cancel(app_adv_data_update_timer_used); app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb); // One second one-shot timer app_easy_gap_undirected_advertise_start(); }
But do you have any idea why the timer cannot be started from the app_init callback?
I searched the documentation and there is no explicit reason why it would not work..
And another (unrelated) question:
I had problems using the UART RX interrupt when using the UART ROM code on the DA14531 (with #undef CFG_UART1_SDK), it never calls the registered callback, and only works when I set to use the SDK UART implementation (#define CFG_UART1_SDK), but I found no information stating why the ROM code would not work, is this a bug on the ROM code? or am I required to always use the compiled driver when dealing with interrupts?
Thanks!
Gustavo
3 weeks ago
Hi gustavo.laureano,
Can you please share the user_app_on_init() and the UART function that you are using in your side?
Thanks, PM_Dialog
3 weeks ago
Here are the relevant parts:
Peripheral initialization on user_periph_setup.c
静态常量uart_cfg_t uart_cfg = {.baud_rate =UART_BAUDRATE_115200, .data_bits = UART_DATABITS_8, .parity = UART_PARITY_NONE, .stop_bits = UART_STOPBITS_1, .auto_flow_control = UART_AFCE_DIS, .use_fifo = UART_FIFO_DIS, .tx_fifo_tr_lvl = UART_TX_FIFO_LEVEL_0, .rx_fifo_tr_lvl = UART_RX_FIFO_LEVEL_0, .intr_priority = 2, }; void periph_init(void) { // In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0); // ROM patch patch_func(); // Initialize peripherals uart_initialize(UART1, &uart_cfg); GPIO_ConfigurePin(UARTx_TX_GPIO_PORT, UARTx_TX_GPIO_PIN, OUTPUT, PID_UART1_TX, false); GPIO_ConfigurePin(UARTx_RX_GPIO_PORT, UARTx_RX_GPIO_PIN, INPUT, PID_UART1_RX, false); // Enable the pads GPIO_set_pad_latch_en(true); }
Code on my user.c:
static void uart_read_cb(uint16_t length) { // Push the received byte into the ring-buffer ringbuffer_add(&ringbuffer_inst_rx, &rxbuf_cb); // Start the next asynchronous read of 1 character. uart_receive(UART1, &rxbuf_cb, 1, UART_OP_INTR); } void user_app_on_init(void) { ringbuffer_init(&ringbuffer_inst_rx, ringbufer_buffer_rx, sizeof(uint8_t), 64); uart_register_rx_cb(UART1, uart_read_cb); uart_receive(UART1, &rxbuf_cb, 1, UART_OP_INTR); /* Start UART reception */ default_app_on_init(); }
Sending data (with uart_send in blocking mode) always works, but receiving data with interrupts only works when I #define CFG_UART1_SDK , otherwise uart_read_cb is never called
3 weeks ago
Hi Gustavo,
谢谢你的问题。我会recommend setting up the timer after the user_app_on_init(). Please try the following changes:
In user_config.h :
In user_callback_config.h :
In user_empty_peripheral_template.h :
In user_empty_peripheral_template.c :
Thanks, PM_Dialog