izmit escort escort ankara adana escort

 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: SAM7X USB write sometimes takes long time
PostPosted: Tue Aug 22, 2017 3:09 pm 
Offline

Joined: Tue Aug 22, 2017 2:33 pm
Posts: 1
Hi,

I'm using SAM7X microcontroller and Atmel device drivers, when I try to write data to USB (CDC driver) sometimes it takes relatively long time (1~2 seconds) which affects CPU load of my application, I tried to check the exact step I found 2 steps that It sometimes waits for transmission to complete for a long time (TXCOMP), as shown in code
Code:
//*----------------------------------------------------------------------------
//* \fn    AT91F_CDC_Write
//* \brief Send through endpoint 2
//*----------------------------------------------------------------------------
static uint AT91F_UDP_Write( AT91PS_CDC pCdc, const char *pData, uint length )
{
    AT91PS_UDP pUdp = pCdc->pUdp;
    uint cpt = 0;

    // Send the first packet
    cpt = MIN( length, AT91C_EP_IN_SIZE );
    length -= cpt;
    while( cpt-- ) pUdp->UDP_FDR[AT91C_EP_IN] = *pData++;
    pUdp->UDP_CSR[AT91C_EP_IN] |= AT91C_UDP_TXPKTRDY;

    while( length )
    {
        // Fill the second bank
        cpt = MIN( length, AT91C_EP_IN_SIZE );
        length -= cpt;
        while( cpt-- ) pUdp->UDP_FDR[AT91C_EP_IN] = *pData++;
        // Wait for the the first bank to be sent

        while( !( pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP ) )      // ISSUE: sometimes, it takes a long time to complete transmission
           if( !AT91F_UDP_IsConfigured( pCdc ) ) return length;

        pUdp->UDP_CSR[AT91C_EP_IN] &= ~( AT91C_UDP_TXCOMP );

        while( pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP );

        pUdp->UDP_CSR[AT91C_EP_IN] |= AT91C_UDP_TXPKTRDY;
    }
    // Wait for the end of transfer

    while( !( pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP ) )      // ISSUE: sometimes, it takes a long time to complete transmission
       if( !AT91F_UDP_IsConfigured( pCdc ) ) return length;

    pUdp->UDP_CSR[AT91C_EP_IN] &= ~( AT91C_UDP_TXCOMP );

    while( pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP );

    return length;
}


I don't know why it takes such long time every now and then and how to overcome it.
Notes
- I'm not familiar with USB driver internals.
- I communicate with a windows 7 machine and libusb-win32 (v1.2.6.0) library

Thanks


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
cron