CDC Send 128_bytes Failure

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

CDC Send 128_bytes Failure

835 Views
CCandido
Contributor V

Hi,

my system to test  CDC Kinetis MK20DX256VLL7, with  C# VS2013, 

whats problems: 

send frame 128 bytes  ARM/ PC = ok 

send frame 16 bytes    PC/ARM  = ok 

send frame  32 bytes   PC/ARM  = OK..failures....OK

send frame 128 bytes  PC/ARM  = Many failures.

all buffers in arm = 128 bytes  CDC1_DATA_BUFF_SIZE 128 and others.

simple test:   

Visual Studio: serialPort1.Write( str_OutBuffer, 0, 128 ); // sendo to ARM

ARM:

loop:

if (CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))!=ERR_BUSOFF){

            if (CDC1_GetCharsInRxBuf()!=0){   // if have bytes received <-------

              lenth = CDC1_GetCharsInRxBuf();              get numbers bytes in buffer received

clear_bufstr( 128);                  //clear buffer + add ( '\0' )
val = bytetochar( lenth );        // convert byte to char(X2)
buf_str[0] = (byte) (val>>8);
buf_str[1] = (byte) (val);
buf_str[127]='#';
WAIT1_Waitms(5);
CDC1_SendString( buf_str);       // send to PC = ok

}

}

results:

arm received: 0x20,0x80,0x40,0x60,0x10.....

how to maker protocols to frame 128 bytes ( char/2 = 64 bytes Hex )

thanks,

Carlos.

Labels (2)
Tags (1)
0 Kudos
Reply
2 Replies

601 Views
mjbcswitzerland
Specialist V

Hi Carlos

There are a few threads that may be related (I didn't find the one that I was hoping to find where there are also suggested workarounds for some problems, but you could spend some time searching more carefully):
https://community.nxp.com/message/814841
https://community.nxp.com/thread/385999?q=virtual%20com
https://community.nxp.com/message/621820

If you don't find a solution take a look at http://www.utasker.com/kinetis/TWR-K20D72M.html
which includes industrial quality USB-CDC operation proven on many Kinetis and Coldfire parts during 8 years of intensive service. Simple to use, allows multiple CDC interfaces at the same time (and multiple CDC to UART bridges with complete end-to-end flow control), plus CDC based RNDIS.
The complete operation can be simulated to allow reviews and accelerate product development.
http://www.utasker.com/docs/uTasker/uTaskerV1.3_USB_Demo.PDF
http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF
http://www.utasker.com/docs/uTasker/uTaskerRNDIS.pdf

Regards

Mark

0 Kudos
Reply

601 Views
CCandido
Contributor V

Hi Mark,

Thank you for your suggestion, 16 bytes the packet does not give, it would be 16 every 10ms of intervals.
I tried to increase the buffer to 128 did not give it, but for 64 bytes it worked, so until there is a stack with a bigger package I will adapt with this one.

#undef CIC_NOTIF_ENDP_PACKET_SIZE
#define CIC_NOTIF_ENDP_PACKET_SIZE (64)
#undef DIC_BULK_IN_ENDP_PACKET_SIZE
#define DIC_BULK_IN_ENDP_PACKET_SIZE (64)/* max supported is 64 */
#undef DIC_BULK_OUT_ENDP_PACKET_SIZE
#define DIC_BULK_OUT_ENDP_PACKET_SIZE (64)/* max supported is 64*/

for error buffre < 64 bytes:

void timer_isr(void){              1ms

if ( CDC1_GetCharsInRxBuf() < 64 ) // no read 

   return...

else

CDC1_GetChar....

-----

}

thanks,

Carlos.

0 Kudos
Reply