cancel
Showing results for 
Search instead for 
Did you mean: 

USB Low-Full-High Speed Peripherals

ShYa_2805961
New Contributor II

Hello,

I am using CY7C65215 USB to UART function, and I want to use UART mode to monitor UART RX line messages(2-line mode). But I don't know use which one API function.

     I saw CyUartRead Function, but I think it only can monitor some time, not always. I mean I want to monitor RX Line always, until my command close this function.Do you know how to implement it?

     if I recall this function by cycles, I afraid I may lost some messages when cycle space. waiting for your ideas.

0 Likes
1 Solution
YatheeshD_36
Moderator
Moderator

Hello Shijie,

Once the function CyUartRead is called, the function will not return until either the buffer is completely filled with data or there is a timeout.

In your case when the length of the buffer is mentioned as 80, the API CyUartRead will return as soon as it receives 80 bytes of data, even when you send more that 80 bytes the function will not consider the rest and hence the transfer count is updated to 80.

Consider this case, the length of the buffer is mentioned as 1000 and time out is mentioned as 5000. In this case when the device(/API) receives only 99 bytes of data and there is a timeout condition, the API will return a timeout error CY_ERROR_IO_TIMEOUT but the transfer count will be updated to 99 and the buffer will be filled with the received 99 bytes of data.

In case if you want to continuously receive data from the UART and display it, you can use UART in CDC mode and an application like tera term for capturing and displaying the data. Please refer to section 3.3.3 UART Configuration from CYUSBS236 DVK User Guide.

Best Regards,

Yatheesh

View solution in original post

0 Likes
7 Replies
YatheeshD_36
Moderator
Moderator

Hello,

You can use the CyUartRead function with a large read buffer length (readbuffer.length) and an infinite timeout (0xFFFFFFFF). Please refer to the below API call

CyUartRead (handle, &cyDatabuffer, 0XFFFFFFFF)

Also please refer to the uart example code given in USB-Serial SDK.

Best Regards,

Yatheesh

0 Likes
ShYa_2805961
New Contributor II

Thanks for your reply.

do you know this parameter's unit? millisecond or second? or 0xFFFF is special value.

I saw this data format is Uint32, so could I set it to 0xFFFFFFFF?

Thanks

0 Likes
YatheeshD_36
Moderator
Moderator

Hello,

The timeout is in milliseconds and for infinite timeout please use 0XFFFFFFFF as its is in UINT32 format.

You can also use timeout value as -1 in place of 0XFFFFFFFF.

Best Regards,

Yatheesh

0 Likes
ShYa_2805961
New Contributor II

Hi Yatheesh

OK, got it.

Do you know how to end UART read function, if I already set CyUartRead timeout value to 0xFFFFFFFF? could I use CyClose(CyHandle) to end this? or call other function?

Thanks

Shijie

0 Likes
ShYa_2805961
New Contributor II

Hi Yatheesh

Sorry for interrupting you again, CyUartRead function behavior is very strange!

I call this function for below:

rStatus = CyUartRead (handle, &cyReadBuffer, 0xFFFFFFFF);

if I don't set cyReadBuffer.Length, then this function will return Error, Error type is 5 (CY_ERROR_INVALID_PARAMETER);

if I set cyReadBuffer.Length= 100, after UART RX Line only get 99 data, then this function will run timeout, will wait always for 100th data.

if I set cyReadBuffer.Length = 80, after UART RX Line get 99 data, when I want to check cyReadBuffer.Length and cyReadBuffer.transferCount, these two parameters are 80, seems they will not be effected by RX Line Data, only is set by users.

So I meet another question, how to get the data and data number  which UART RX Line already got? and How to know UART RX Line already get the data?

Thanks

Shijie

0 Likes
YatheeshD_36
Moderator
Moderator

Hello Shijie,

Once the function CyUartRead is called, the function will not return until either the buffer is completely filled with data or there is a timeout.

In your case when the length of the buffer is mentioned as 80, the API CyUartRead will return as soon as it receives 80 bytes of data, even when you send more that 80 bytes the function will not consider the rest and hence the transfer count is updated to 80.

Consider this case, the length of the buffer is mentioned as 1000 and time out is mentioned as 5000. In this case when the device(/API) receives only 99 bytes of data and there is a timeout condition, the API will return a timeout error CY_ERROR_IO_TIMEOUT but the transfer count will be updated to 99 and the buffer will be filled with the received 99 bytes of data.

In case if you want to continuously receive data from the UART and display it, you can use UART in CDC mode and an application like tera term for capturing and displaying the data. Please refer to section 3.3.3 UART Configuration from CYUSBS236 DVK User Guide.

Best Regards,

Yatheesh

View solution in original post

0 Likes
ShYa_2805961
New Contributor II

Yes, you are right.

Thanks for your patience.

I will implement this feature by CDC mode

Shijie

0 Likes