UART RX stream stops when receiving special characters

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART RX stream stops when receiving special characters

2,201 Views
panpwr
Contributor IV

Hello,

I am using an interrupt-driven UART port with MQX 4.0.

Here are the strings I see using an external terminal console (the expected result):

Terminal:

at+iRP1

ID809b16 11.6.2012

I/OK

And here is what i get from UART:

at+iRP1\r\n

ID809b16 11.6.2012\r\n

I      <=== Missing chars: "/OK"

The second batch actually comes through fine, even with the special char "/":

Terminal = UART:

at+iRP1

I/OK

However, the 3rd batch stops at a special character as well:

Terminal:

at+iRP3

0801 9.6.2009

I/OK


UART:

at+iRP3

0801 9   <=== Missing chars: ".6.2009"

             <=== Missing chars: "I/OK"


This is my receptions code:

if (_io_fstatus(ch))

{

   //Pending char in UART

   rx_uart = fgetc(connect_one_ch);

}

I've opened the UART descriptor using io_open, with no flags. What am I missing here? Please notice that the problem persists when I try to receive 3 lines from UART. Is there a special property I need to set?

Thanks,
Lior.

Tags (3)
0 Kudos
Reply
5 Replies

1,514 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Panpwr,

It is possible that you are using the default open flags. This is the default:

 

#define BSP_DEFAULT_IO_OPEN_MODE (pointer) (IO_SERIAL_XON_XOFF | IO_SERIAL_TRANSLATION | IO_SERIAL_ECHO)

I suggest you add this line to the user_config.h file:

#define BSP_DEFAULT_IO_OPEN_MODE (pointer) (IO_SERIAL_XON_XOFF | IO_SERIAL_ECHO)

You will see that the flag IO_SERIAL_TRANSLATION was removed. Don't forget to recompile the BSP library before compiling again your application. I hope this helps.

Have a nice day.

-Garabo

0 Kudos
Reply

1,514 Views
panpwr
Contributor IV

Unfortunately, this doesn't work - I get some of the characters, and other i don't.

I get the same results, when changing from open mode from IO_SERIAL_XON_XOFF to IO_SERIAL_NON_BLOCKING.

Also, adding delays between tx and rx change the results a bit:


*** Receiving First batch of strings: ***

Terminal:

AT+iRP1

ID809b16 11.6.2012

I/OK

Everything was received correctly from UART.

*** Receiving Second batch of strings: ***

Terminal:

+++I/ERROR (056)


And here is what i get from UART:

+++ <=== Missing chars: "I/ERROR (056)"

Missing characters when reading from UART.

*** Receiving Third of strings: ***

Terminal:

AT+iRP1

ID809b16 11.6.2012

I/OK

And here is what i get from UART:

IAT+iRP1 <=== A spare char: "I"

ID809b16 11.6.2012

I/OK

Spare character when reading from UART - probably one of the missing chars from the previous batch.


It seems that something with the buffer or reception timings is wrong.

Do you have any suggestions?


Thanks,

Lior.

0 Kudos
Reply

1,514 Views
panpwr
Contributor IV

More questions regarding the UART:

1. Am I using the UART driver properly? Do I really need to poll the device for data arrival in serial-interrupt mode?

2. Can't I use a callback function that will notify me whenever a specific event occurs ((e.g., "\n" character arrives)? If so, then what is the difference between serial-polled & serial-interrupt modes?

0 Kudos
Reply

1,514 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Let me answer to each or your questions:

1. You can find that the appnote AN4022 shows the right usage of the UART interrupt driver. It is similar to what you are doing but with a IOCTL() call.

2. You cannot set a callback function. The interrupt is happening at the driver level. You could set events and set them from the application.

I hope this helps.

Best Regards,

-Garabo

0 Kudos
Reply

1,514 Views
panpwr
Contributor IV

Hello,

I've read AN4022 "IP Camera and USB Snapshot with MQX", and couldn't see any code which uses the UART driver (only initialization in user_config.h).

You've mentioned that I can use Events to notify the application about different occurrences. How can I notify the application that it needs to check the UART buffer?

Thanks,

Lior.

0 Kudos
Reply