View previous topic :: View next topic |
Author |
Message |
Rod_proteus
Joined: 18 Jun 2015 Posts: 2
|
USB CDC : Delay between data while sending !! |
Posted: Thu Jun 18, 2015 10:21 am |
|
|
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
|
|
Posted: Thu Jun 18, 2015 11:40 am |
|
|
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
|
|
Posted: Thu Jun 18, 2015 12:51 pm |
|
|
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
|
|
Posted: Thu Jun 18, 2015 2:07 pm |
|
|
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. |
|
|
|