USB 4.0.3 CDC HOST example doesn't receive data

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB 4.0.3 CDC HOST example doesn't receive data

Jump to solution
1,815 Views
pedropol
Contributor II

I'm using the example for Freescale USB Stack v4.0.3\ProcessorExpert\Examples\Host\CDC\USB_CDC_HOST_MKL25Z128_PEx on FRDM-KL25Z board.

I can send data from Host to CDC device but not from Device to HOST. It doesn't works. Host doesn't receive nothing.

Function  _io_cdc_serial_read always return 0.

If I connect the device to a PC,  I can see, in the hyperterminal, the data sent, so the problem seems to be on the host.

I've use the size of reception buffer like num parameter but also I've tried  other different values (1; 8 ; 16 ) but nothing.

Message to receive is sent correctly to the queue.


I set a breakpoint in usb_class_cdc_in_data_callback funtion (usb_host_cdc.c file) and the line "acm_if_ptr->ctrl_state.bmStates[1] & USB_ACM_LINE_STATE_DTR  always set "len" to 0


If acm_if_ptr->ctrl_state.bmStates[1] is not  USB_ACM_LINE_STATE_DTR  is the reception disabled?

Where, and when,   is acm_if_ptr->ctrl_state.bmStates[1] set?


Where I must to set other breakpoints to debug and check if data is arriving or not?



0 Kudos
Reply
1 Solution
1,320 Views
florintoma
NXP Employee
NXP Employee

     Sorry for this late reply. I have found a bug in usb_host_cdc.c. In the usb_class_cdc_set_acm_ctrl_state() function, at lines 350 / 351 if_acm_ptr->ctrl_state.bmStates[1] should be changed with if_acm_ptr->ctrl_state.bmStates[0]. The problem was that the state was sent on the usb in big endian instead of little endian.

View solution in original post

0 Kudos
Reply
4 Replies
1,320 Views
pedropol
Contributor II

Example has:

const CDC_SERIAL_INIT   usb_open_param = {

  USB_UART_NO_BLOCKING | USB_UART_HW_FLOW

};

Disabling USB_UART_HW_FLOW, I started to receive messages from cdc device.

Host can works without USB_UART_HW_FLOW?

I need to set anything in host, or device, to work correctly with USB_UART_HW_FLOW enabled?

0 Kudos
Reply
1,321 Views
florintoma
NXP Employee
NXP Employee

     Sorry for this late reply. I have found a bug in usb_host_cdc.c. In the usb_class_cdc_set_acm_ctrl_state() function, at lines 350 / 351 if_acm_ptr->ctrl_state.bmStates[1] should be changed with if_acm_ptr->ctrl_state.bmStates[0]. The problem was that the state was sent on the usb in big endian instead of little endian.

0 Kudos
Reply
1,320 Views
florintoma
NXP Employee
NXP Employee

If no data is received in host mode, please check if you have PORTB11 on output and set to 1. That is the enable pin for MIC2026 switch to power the USB, or you can use the code below.


      /* Trigger Enable pin for MIC2026 switch  */

   SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;   /* enable clock gating */

   PORTB_PCR11 = PORT_PCR_MUX(1);       /* GPIO mux */

   GPIOB_PDDR |= 1<<11;                 /* output pin */

   GPIOB_PSOR |= 1<<11;                 /* set pin value to 1 */


0 Kudos
Reply
1,320 Views
pedropol
Contributor II

Thanks , but this configuration is for TWR.KL25Z board?

I'm using a modded (for have 5V on the USB connector ) FRDM-KL25Z board 

0 Kudos
Reply