USB IN with data smaller than the DMA buffer.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 I need to be able to send 4 bytes out of the FX3 when a request comes from the host. I am using an audio feedback application. I have exerprimented by using the firmware project USBBulkSourceSink. I changed the endpoint config as below

   

 

   
        CyU3PMemSet ((uint8_t *)&epCfg, 0, sizeof (epCfg));   
   
        epCfg.enable = CyTrue;   
   
        epCfg.epType = CY_U3P_USB_EP_BULK;   
   
        epCfg.burstLen = (usbSpeed == CY_U3P_SUPER_SPEED) ?   
   
            (CY_FX_EP_BURST_LENGTH) : 1;   
   
        epCfg.streams = 0;   
   
        epCfg.pcktSize = 4;   
   
        
   
    And the DMA setup    
   
        
   
    
        dmaCfg.size = 16;    
    
         dmaCfg.count = 1;    
    
         dmaCfg.prodSckId = CY_U3P_CPU_SOCKET_PROD;    
    
         dmaCfg.consSckId = CY_FX_EP_CONSUMER_SOCKET;    
    
         dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;    
    
         dmaCfg.notification = CY_U3P_DMA_CB_CONS_EVENT;    
    
         dmaCfg.cb = CyFxBulkSrcSinkDmaCallback;    
    
         dmaCfg.prodHeader = 0;    
    
         dmaCfg.prodFooter = 0;    
    
         dmaCfg.consHeader = 0;    
    
         dmaCfg.prodAvailCount = 0;    
    
          
    
     I have initilised the DMA buffer with a counting pattern 0, 1, 2 ... 14, 15. When I try the example in control centre I get the following    
    
          
    
     
      BULK IN transfer      
     
      0000 00 01 02 03     
     
      BULK IN transfer completed     
     
            
     
      BULK IN transfer      
     
      0000 08 09 0A 0B     
     
      BULK IN transfer completed     
     
            
     
      
       BULK IN transfer       
      
       0000 00 01 02 03      
      
       BULK IN transfer completed      
      
              
      
       BULK IN transfer       
      
       0000 08 09 0A 0B      
      
       BULK IN transfer completed      
     
     
            
     
      So it seems that it sends the first 4 bytes, then skips the next 4 bytes, then sends the next 4 bytes. The last 4 bytes are skipped then as I have only 1 DMA buffer it starts from the top again. I was expecting it to send the first 4 bytes then start again with the first 4 bytes. I also have a callback function but this only gets called every other time (on the 08 09 0a 0b bytes). Can somone explain what is happening?     
     
            
     
            
     
      Thanks     
     
            
     
      Jon     
    
   
0 Likes
2 Replies
Anonymous
Not applicable

 Just worked out that I needed to change the following function

   

 

   

status = CyU3PDmaChannelCommitBuffer (chHandle, buf_p.size, 0);

   

 

   

to

   

 

   

/status = CyU3PDmaChannelCommitBuffer (chHandle, 4, 0);

0 Likes
Anonymous
Not applicable

Right. Thanks for updating the thread.

   

Thanks,

   

sai krishna.

0 Likes