CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

USB CDC : Delay between data while sending !!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Rod_proteus



Joined: 18 Jun 2015
Posts: 2

View user's profile Send private message

USB CDC : Delay between data while sending !!
PostPosted: Thu Jun 18, 2015 10:21 am     Reply with quote

Hi guys:

I got an issue with CDC (serial port emulation) -> I'm sending to and receiving data from computer using a custom "PC application". This app. measures time between incoming bytes to get a new "incoming packet". For instance, if pc detects more than 200 [ms] between 2 incoming bytes then pc says NEW PACKET (this kind of synchronization is called byte TimeOut) .
Also, I can't modify this application because I don't have source code.

Well. I wrote a simple code in PICC compiler to send data by serial port emulation (USB CDC) to PC. It works fine. BUT, I have a problem when I try to send more than 63 bytes at once. If I send more than 63 bytes the pc application detects a time (enough longer) between the byte number 63 and 64 and it says: "New packet".


I wrote the SAME simple code in MPLAB (using C30) and no problem sending data to PC (regardless total of bytes to send).

Checking the files included in PICC I noticed the following macros:


USB_NONISO_PACKET_MAX_SIZE = 64

and

USB_CDC_DATA_IN_SIZE = 64

I tried to modify these macros but It didn't work.

Please, do you have any ideas to resolve this issue ?...
Thanks.

PS: I'm using PCW , version 5.045
and PIC24EP512GU810
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Thu Jun 18, 2015 11:40 am     Reply with quote

I've pushed over 500000bytes/second using the standard code, so something wrong is happening in the way it is being used.

Are you using interrupt driven or polled?. How often are you calling usb_task?. (this still needs to be called even when interrupt driven transmission is used - it does the housekeeping). Are you sending through usb_puitc, or trying to do a direct packet write?.

64bytes, is the maximum packet size for a bulk mode transfer. Have a look at:

<https://www.ccsinfo.com/forum/viewtopic.php?t=40422>

This is part of the USB spec, so you can't change this.
Rod_proteus



Joined: 18 Jun 2015
Posts: 2

View user's profile Send private message

PostPosted: Thu Jun 18, 2015 12:51 pm     Reply with quote

Ttelmah:
Thanks for replying...

Well.. Either polling or interrupt the result is the same (I'm using polling).

Just for avoiding misunderstandings... My pic code works sending 64 or more bytes by usb emulating a serial port. I mean, if I want to send 1024 bytes to pc, the pic sends the total bytes (1024). That's not the problem... the problem is the "delay" that the pic forces between bytes 63 - 64, 127 - 128, and so on.

This code has been wrote in PICC and MPLAB (c30). Only C30 works fine !!!

Code:

void main(void)
{
    int  iVar = 0;

    InitializeBoard();

    while(1)
    {
          usb_task();
       
          if(iVar == 0)
          {
              iVar = 1;

              usb_cdc_putd(buffer, 250);

             }
    }

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Thu Jun 18, 2015 2:07 pm     Reply with quote

There is always going to be a break at that point, but not 200mSec.
It is the master device that polls the CDC device. Try reducing the polling interval in the endpoint descriptor. I'd suspect the CCS default is set a lot higher (remember this reduces overall USB bandwidth for other devices on the bus if set low...). However the default was something like 10mSec if I remember correctly.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group