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

USB COM CDC on android

Hi everyone!

I have recently implemented USB CDC on a custom NRF52840 device with SDK 15.0 and got it to work with Windows, Mac, and Linux OS. However, when I try it on an Android device I can't seem to get it to connect and send/receive any data. I can see the device by using any USB serial terminal application available on play store, such as,  Serial terminal or USB Serial terminal. The device appears in the list and can see the correct PID/VID, but as I establish a connection with the device I receive an error that the controlTransfer failed, can't seem to find anything about this error somewhere when searching on android forums.

My question is whether I have to do anything in the software to enable the device to communicate with an Android device? It is working without any problems on all other operative systems that I have tried on but not on Android devices. Have also tried different adapters and three different Android devices and all show the same error. 

I really appreciate any help I could get

Best regards

Hadi

Parents
  • UPDATE:

    I tested the original USBD CDC ACM example and seem to work, but the application that I have made does not work with Android. When comparing the two applications, the only difference in the code is that I had not added nrf_drv_clock_init, app_usbd_power_events_enable, and some of the defines related to nrf power are set to 0. I tried to add these and change the defines but the application fail during init of the usbd

    When calling nrf_drv_clock_init, I get <error> app: Fatal error

    If I am using a softdevice should I still call nrf_Drv_clock_init?

    I have also these configurations in sdk config, could this be the cause of the application failing?

    // <0=> NRF_CLOCK_LF_SRC_RC 
    // <1=> NRF_CLOCK_LF_SRC_XTAL 
    // <2=> NRF_CLOCK_LF_SRC_SYNTH 
    
    #ifndef NRF_SDH_CLOCK_LF_SRC
    #define NRF_SDH_CLOCK_LF_SRC 1
    #endif
    
    // <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. 
    #ifndef NRF_SDH_CLOCK_LF_RC_CTIV
    #define NRF_SDH_CLOCK_LF_RC_CTIV 0
    #endif
    
    // <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. 
    // <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
    // <i>  if the temperature has not changed.
    
    #ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
    #define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0
    #endif
    
    // <o> NRF_SDH_CLOCK_LF_ACCURACY  - External clock accuracy used in the LL to compute timing.
     
    // <0=> NRF_CLOCK_LF_ACCURACY_250_PPM 
    // <1=> NRF_CLOCK_LF_ACCURACY_500_PPM 
    // <2=> NRF_CLOCK_LF_ACCURACY_150_PPM 
    // <3=> NRF_CLOCK_LF_ACCURACY_100_PPM 
    // <4=> NRF_CLOCK_LF_ACCURACY_75_PPM 
    // <5=> NRF_CLOCK_LF_ACCURACY_50_PPM 
    // <6=> NRF_CLOCK_LF_ACCURACY_30_PPM 
    // <7=> NRF_CLOCK_LF_ACCURACY_20_PPM 
    // <8=> NRF_CLOCK_LF_ACCURACY_10_PPM 
    // <9=> NRF_CLOCK_LF_ACCURACY_5_PPM 
    // <10=> NRF_CLOCK_LF_ACCURACY_2_PPM 
    // <11=> NRF_CLOCK_LF_ACCURACY_1_PPM 
    
    #ifndef NRF_SDH_CLOCK_LF_ACCURACY
    #define NRF_SDH_CLOCK_LF_ACCURACY 7
    #endif

  • If I am using a softdevice should I still call nrf_Drv_clock_init?

    The driver nrf_drv_clock should handle that fine, as long as you have the SOFTDEVICE_PRESENT preprocessor define. My guess is that you are getting the NRF_ERROR_MODULE_ALREADY_INITIALIZED error. If you want BLE+USBD CDC ACM, you should take a look at the usbd_ble_uart example. (PS; If you are on SDK 15.0, take look at this post.)

    When calling nrf_drv_clock_init, I get <error> app: Fatal error

    Add DEBUG as preprocessor define, and the error-code should be printed instead. If you are using SES, you only need to set the build configuration to "Debug".

Reply Children
No Data
Related