USBUART can not receive data from HOST(PC)

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

cross mob
T_Mura
Level 2
Level 2
10 replies posted 5 questions asked 5 replies posted

Like a Hyper Terminal terminal as COM test software on HOST.

Data receve from the USBUART is work well.(check with terminal software)

  ・The sample code is as follows

 if(CHP.TUACHON != CHP.TUACH_BK) 

 {

  CHP.TUACH_BK = CHP.TUACHON;

  if(CHP.TUACHON)

    USB_TxData("T-ON");

  else

    USB_TxData("T-OFF");

  }

 }

void USB_TxData(char *Str)

{

while(USBUART_CDCIsReady() == 0);

USBUART_PutString(Str);

}

---------------------------------------------------------

Received data  chack routine is as follows

---------------------------------------------------------

while(1) {

   if(USBUART_DataIsReady() > 0)

        {

      USB_TxData("Get data=");

      USBUART_GetAll(&buff[0]);

      }

}

The problem is that this USBUART_DataIsReady () functionIt does not return a value of greater than 0.

I look forward to good advice.  Thank you

0 Likes
1 Solution
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

Hello,

The things to be noted down is :

>> Move the USBUART_DataIsReady()  and corresponding code to do while(1) function body, USBUART_DataIsReady()  is returning non zero when it receives data from terminal otherwise if you check at a time instance when it has not received any data from terminal, it will return zero.

>>Use

while(0==USBUART_GetConfiguration()) {};

instead of

while(USBUART_GetConfiguration()) {};

Thanks,

Ankita

View solution in original post

0 Likes
11 Replies
lock attach
Attachments are accessible only for community members.
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

Hello,

Can you please check the project attached.In this project USBUART_DataIsReady () function gives non-zero value.

Thanks,

Ankita

0 Likes

Changed as follows according to the sample code

The result was the same.

if(USBUART_DataIsReady() > 0) --> if(USBUART_DataIsReady() != 0)

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

I didn't meant that  that changing if(USBUART_DataIsReady() > 0)  to  if(USBUART_DataIsReady() != 0) will help.

I meant check whether you are using USBUART_DataIsReady() at correct place in code.

Can you share your project.

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

It’s ok.

I attached the circuit diagram and the project.

please confirm.

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

Hello,

I cannot open the PSoC Creator project attached in PSoC  Creator 4.2.

Can you please open the PSoC Creator project in PSoC  Creator 4.2, then right click it and choose to Archive it with option  " Complete".

Then send that archived project available in Archive named Folder available within the .cydsn project folder.

Thanks,

Ankita

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

Hellow

Send archive file created with Psoc 4.2.

Please check it out.

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

Hellow

I have additional information.

1. Device manager in windows 10State. (Refer to attached file)

2. Currently in 106 lines while () function.There is a problem.

If bypass this function,

Line 135 from DO {}, It has been confirmed that the series of operations are working properly.

Thank you.

0 Likes
lock attach
Attachments are accessible only for community members.
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

Hi,

Your observation is correct.

In your project attached, you are checking USBUART_DataIsReady() only once in while (Flag) condition body, but if you move the USBUART_DataIsReady()  and corresponding code to do while(1) function body, USBUART_DataIsReady()  is returning non zero when it receives data from terminal.

I have verified this and attaching the modified project.

Thanks,

Ankita

0 Likes

As a result of checking the operation of the changed program, it has been confirmed that it is operating properly.

So I checked the original code again, I found a big mistake.

A series of codes in the USB_Initialize () function It was as follows.

USBUART_Start(0, USBUART_3V_OPERATION);

while(USBUART_GetConfiguration()) {};

USBUART_CDC_Init();

So I changed it as follows All solved.

;

while(0==USBUART_GetConfiguration()) {};

;

Thank you

0 Likes

Hi

Finally

The process for closing this subject is What should I do?

Thanks

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

Hello,

The things to be noted down is :

>> Move the USBUART_DataIsReady()  and corresponding code to do while(1) function body, USBUART_DataIsReady()  is returning non zero when it receives data from terminal otherwise if you check at a time instance when it has not received any data from terminal, it will return zero.

>>Use

while(0==USBUART_GetConfiguration()) {};

instead of

while(USBUART_GetConfiguration()) {};

Thanks,

Ankita

0 Likes