This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB CDC ACM Example Single Write

Hello,

we are using the USB CDC ACM Example to set up a USB connection between the computer and the nRF-Chip. By pressing Press Button 1 a bunch of test data will be sent to the terminal program (after a short delay).

But how is it possible to set up a instantaneous data-transfer of a single data array (for example after a button was pressed). It seems like the data are only transmitted after multiple callings of the function app_usbd_cdc_acm

Setup: nRF5 SDK v13.0.0 USB CDC ACM Example; nRF52840-Preview-DK

With kind regards

Fabian

Parents
  • Hi Fabian,

    In the USB CDC ACM example, the state of the buttons are checked inside an endless while-loop inside main function. If the button is pressed, a write will be performed. If holding down the button, the loop will cause multiple writes.

    If you want to write a single data array, you can call app_usbd_cdc_acm_write() anywhere in your code:

    static uint8_t m_tx_buffer[NRF_DRV_USBD_EPSIZE * 16] = {'P','u','t',' ','d','a','t','a',' ','h','e','r','e','\r','\n','\0'};
    app_usbd_cdc_acm_write(&m_app_cdc_acm, m_tx_buffer, sizeof(m_tx_buffer));
    

    Best regards,

    Jørgen

Reply
  • Hi Fabian,

    In the USB CDC ACM example, the state of the buttons are checked inside an endless while-loop inside main function. If the button is pressed, a write will be performed. If holding down the button, the loop will cause multiple writes.

    If you want to write a single data array, you can call app_usbd_cdc_acm_write() anywhere in your code:

    static uint8_t m_tx_buffer[NRF_DRV_USBD_EPSIZE * 16] = {'P','u','t',' ','d','a','t','a',' ','h','e','r','e','\r','\n','\0'};
    app_usbd_cdc_acm_write(&m_app_cdc_acm, m_tx_buffer, sizeof(m_tx_buffer));
    

    Best regards,

    Jørgen

Children
Related