Hello, I'm developing a BLE mouse using nRF52840.
I found something strange while testing mouse movement by connecting the BLE.
I was logging using the RTTViewer and found that the BLE only works normally when the logger is in operation.
Here is the description of the attached video.
1. I modified the firmware so that the mouse moves automatically.
2. I connected my mouse and PC with BLE and started to record this video.
3. I recorded when I connected the RTT Viewer and when I didn't. Please look at the mouse's movements.
4. The numbers 39, 40 in the logger are outputting the return value of app_sched_queue_space_get().
The following is an approximate initialization code.
//log init
NRF_LOG_INIT(NULL);
NRF_LOG_DEFAULT_BACKENDS_INIT();
//timer init
nrf_drv_clock_init();
nrf_drv_clock_lfclk_request(NULL);
app_timer_init();
//pwr mgmt init
nrf_pwr_mgmt_init()
//schedler init
APP_SCHED_INIT(sizeof(my_event_t), SCHED_QUEUE_SIZE:40);
//cli init
nrf_cli_init(const p_cli*:&m_cli_rtt, void* p_transport_config:NULL, int use_color:true, int log_backend:true, int LOG_LVL)
nrf_cli_start(&m_cli_rtt);
//twi init
nrf_twi_mngr_init(g_twi_mnger, twi_config)
twi_probe()
//usb init
app_usbd_init(&usbd_config);
app_usbd_class_append(app_usbd_hid_mouse_class_inst_get(&m_app_hid_mouse););
app_usbd_class_append(app_usbd_hid_kbd_inst_get(&m_app_hid_kbd));
app_usbd_class_append(app_usbd_hid_generic_class_inst_get(&m_app_hid_generic));
//BLE init
buffer_init();
ble_stack_init();
{
nrf_sdh_enable_request();
nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
nrf_sdh_ble_enable(&ram_start);
NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
sd_power_dcdc_mode_set(NRF_POWER_DCC_ENABLE);
}
gap_params_init();
{
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
sd_ble_gap_device_name_set(&sec_mode, device_name, device_name_len);
sd_ble_gap_appearance_set(BLE_APPEARANCE_HID_KEYBOARD);
sd_ble_gap_ppcp_set(&gap_conn_params)
}
nrf_ble_gatt_init(&m_gatt, gatt_evt_handler)
dis_init();
bas_init();
hids_init();
ble_conn_params_init(&cp_init);
pm_init();
pm_sec_params_set(&sec_param);
pm_register(mkb_ble_pm_evt_handler);
ble_advertising_init(&m_advertising, &init);
ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
//fds init
fds_register(fds_evt_hadler);
fds_init();
fds_wait_for_ready();
//wdt init
nrf_drv_wdt_init(&config, wdt_event_handler);
nrf_drv_wdt_channel_alloc(&m_wdt_channel_id);
//event_init
nrf_balloc_init(&s_event_pool);
//i2c handler init
drv_my_chip_init(touchpad_read_handler)
//adc init
mkb_battery_sensor_adc_init();
app_timer_create(&m_battery_timer_id, APP_TIMER_MODE_REPEATED, battery_level_mean_timeout_handler)a
//pwm init
app_timer_create(&m_led_timer, APP_TMER_MODE_REPEATED, mkb_led_timer_handler)
nrf_drv_pwm_init(&m_pwm1, &led1_cfg, NULL)
nrf_drv_pwm_init(&m_pwm2, &led2_cfg, NULL)
nrf_drv_pwm_init(&m_pwm3, &led3_cfg, NULL)
nrf_drv_pwm_init(&m_pwm4, &led4_cfg, NULL)
I don't know how RTT Viewer could affect BLE.
Please help me.