end point not transferring data

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

cross mob
Anonymous
Not applicable

 Hi guys,

   

I am using an adc and USBFS (not USBUART) in a project. The adc output is being displayed on the lcd and simultaneously also being loaded into the endpoint of usb. I have configured usbfs for bulk transfer with endpoint 1 set for IN mode.

   

However on execution, the transfer is not taking place and the program gets stuck at this command:

   

while(USBFS_GetEPState(IN_EP)!=USBFS_IN_BUFFER_EMPTY);

   

I have attached my project file under the folder name "proj3".

   

I would be grateful for any suggestions quickly.

0 Likes
8 Replies
Anonymous
Not applicable
0 Likes
Anonymous
Not applicable

 I AM UNABLE TO POST MY FILE .I WILL SEND YOU GUYS THE CODE ITSELF.

0 Likes
Anonymous
Not applicable

 ========================================

   
    */   
   
    #include <device.h>   
   
    #include <stdio.h>   
   
    #include <string.h>   
   
        
   
    #define IN_EP (0x01u)  /*end point IN1*/   
   
        
   
        
   
    void main()   
   
    {   
   
        /* Place your initialization/startup code here (e.g. MyInst_Start()) */   
   
        int32 output;   
   
        char8 str[10]={0};   
   
        uint16 len;    
   
           
   
        LCD_Start();   
   
        VDAC_Start();   
   
        IDAC_1_Start();   
   
        IDAC_2_Start();   
   
        TIA_1_Start();   
   
        TIA_2_Start();   
   
        ADC_Start();   
   
        CyGlobalIntEnable;    /*always include this command for recognising usb devices*/   
   
        USBFS_Start(0,USBFS_3V_OPERATION);   
   
           
   
           
   
        TIA_1_SetResFB(TIA_1_RES_FEEDBACK_20K);   
   
        TIA_2_SetResFB(TIA_2_RES_FEEDBACK_20K);   
   
            
   
        LCD_Position(0u,3u);   
   
        LCD_PrintString("ADC OUTPUT");   
   
           
   
        ADC_StartConvert();   
   
           
   
        while(!USBFS_GetConfiguration());   
   
        len=strlen(str);    
   
           
   
        USBFS_LoadInEP(IN_EP,&str[0],len); /*send a blank string*/   
   
          
   
             
   
        for(;;)   
   
        {   
   
           ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);   
   
           output=ADC_GetResult32();   
   
           output=ADC_CountsTo_uVolts(output);   
   
              
   
           /*To account for offset error*/   
   
           if(output>0)   
   
           output=output-1500;   
   
           else   
   
           output=output+1500;   
   
              
   
           sprintf(str,"%7ld",output);   
   
           LCD_Position(1u,3u);   
   
           LCD_PrintString(str);   
   
           len=strlen(str); /*calculate length of string to load in IN buffer*/   
   
              
   
           while(USBFS_GetEPState(IN_EP)!=USBFS_IN_BUFFER_EMPTY);/*load the in buffer if it is empty*/   
   
              
   
            USBFS_LoadInEP(IN_EP,&str[0],len);   
   
               
   
              
   
        }   
   
    }   
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

For uploading files, use Firefox or IE, but not Chrome.

   

One question: do you have a program running at the other side of your USB connection that actually reads the data? Does the program get stuck on the first time it sends data or only on the second time? (OK, that were now two questions 🙂

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

There is no program running on the PC side to read the data. However, i plan to use Labview later.

0 Likes
Anonymous
Not applicable

To answer your second question :), it gets stuck at the first run itself and the lcd displays only one value.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

I'm not sure how your endpoint is configured. But if there is no one on the PC side to read the data, maybe the PSoC ist just not able so send the buffer fully...

0 Likes
Anonymous
Not applicable

 In the project file that i attached in my previous post, the endpoint 1is configured as bulk transfer with packet size of maximum 64 bytes.

0 Likes