1 month 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
要使广告数据动态,但由于某种原因,在从user_app_on_init调用时无法启动计时器,但在从另一个地方调用时工作(如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)
任何想法为什么要从init开始的计时器?
谢谢
此致
Gustavo
1 month ago
嗨PM_DIALOG.
谢谢,它有效,当我从adv_start用户回调开始时,我所做的唯一更改就是始终取消任何以前的计时器,否则它正在生成并行运行的多个计时器实例:
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 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?
谢谢!
Gustavo
1 month ago
Hi gustavo.laureano,
Can you please share the user_app_on_init() and the UART function that you are using in your side?
谢谢, PM_Dialog
1 month 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){//在Boost模式下,使DCDC转换器能够为已使用的GPIOS Syscntl_dcdc_turn_oN_in_in_In_Boost提供vbat_high供应Vbat_high(syscntl_dcdc_level_3v0);// rom修补程序patch_func();//初始化外设UART_INITIALIZE(UART1,&UART_CFG);gpio_configurepin(uartx_tx_gpio_port,uartx_tx_gpio_pin,输出,pid_uart1_tx,false);GPIO_CONFIGUREPIN(UARTX_RX_GPIO_PORT,UARTX_RX_GPIO_PIN,INPUT,PID_UART1_RX,FALSE);//启用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
1 month 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 :
谢谢, PM_Dialog