Hi all!
I use the ACM_CDC USB class to transfer a batch of data (150MB) from the MCU (nrf52840) to the host. Currently, the system reaches up to 100KB/s upload speed, although the USB bus is at 12Mbps.
My main, with USBD queue disabled:
int main(void) {
ret_code_t ret;
static const app_usbd_config_t usbd_config = {
.ev_state_proc = usbd_user_ev_handler, .ev_handler = _svExecuteEvents};
ret = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(ret);
ret = nrf_drv_clock_init();
APP_ERROR_CHECK(ret);
app_usbd_serial_num_generate();
ret = app_usbd_init(&usbd_config);
APP_ERROR_CHECK(ret);
app_usbd_class_inst_t const *class_cdc_acm =
app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm);
ret = app_usbd_class_append(class_cdc_acm);
APP_ERROR_CHECK(ret);
if (USBD_POWER_DETECTION) {
ret = app_usbd_power_events_enable();
APP_ERROR_CHECK(ret);
} else {
NRF_LOG_INFO("No USB power detection enabled\r\nStarting USB now");
app_usbd_enable();
app_usbd_start();
}
while (true) {
}
}
The user event handler:
static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const *p_inst,
app_usbd_cdc_acm_user_event_t event) {
switch (event) {
case APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN:
app_usbd_cdc_acm_write(&m_app_cdc_acm, m_tx_buffer, sizeof(m_tx_buffer));
break;
case APP_USBD_CDC_ACM_USER_EVT_TX_DONE:
app_usbd_cdc_acm_write(&m_app_cdc_acm, m_tx_buffer, sizeof(m_tx_buffer));
break;
}
}
The event execution handler:
static void _svExecuteEvents(app_usbd_internal_evt_t const *const p_event) {
app_usbd_event_execute(p_event);
}
And the signal on USB pin 3 while uploading data:
Do you know why there are so many gaps between the data in the oscilloscope screenshot? Could this be a firmware problem? Or an issue/limitation on the host side?
Thank you,
Chris