Why do I receive some messy characters by flexio_uart ?

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

Why do I receive some messy characters by flexio_uart ?

2,390 Views
Ashlie
Contributor III

Hello,

I use flexio to configure a uart mode, and receive datas in interrupt by pin D6.The driver code is from EB tresos. Finally I find a strange thing that I can't get each right character when I use rx interrupt.For example, if  I set 

Uart_AsyncReceive( 3, &test_rx_data_u8g, 1);
,
I will get some messy characters from the second character when I want to get a lot of continuous characters.
However, if I set 
Uart_AsyncReceive( 3, test_rx_data_u8g, 10);
,
I will get all the right 10 characters as long as I send over 10 from PC.
 
At last, I find a error interrupt would occur after get the first character.
What's wrong?
Tags (2)
0 Kudos
Reply
11 Replies

2,362 Views
cuongnguyenphu
NXP Employee
NXP Employee

Can you attach your configuration also?

 

0 Kudos
Reply

2,314 Views
Ashlie
Contributor III

Hi,

The configuration in the MCL is here:

Ashlie_0-1683197510967.png

Ashlie_3-1683198204024.png

 

I find that if i shield someplace, I will get the completely right data:

Ashlie_2-1683197676691.png

But I still don't know the real reason. I guess maybe there is something to do with the shift register and timer's configurations and also with the work timing. Could you please explain it more clear?

Thanks!

0 Kudos
Reply

2,298 Views
cuongnguyenphu
NXP Employee
NXP Employee

Hi @Ashlie 
Could you let us know which HW target you're working on, and which SW package version you used (RTD package or MCAL package? )
The configuration file I mentioned is .xdm files in EB Tresos that you configure for Uart and MCL modules

0 Kudos
Reply

2,295 Views
Ashlie
Contributor III

Hi @cuongnguyenphu ,

I use S32K144 mcu, and the EB's version is 26.0.1. There is some information I can get from the sw uart module:

Ashlie_0-1683595322714.png

But a embarrassing thing is that I don't know how to insert the .xdm files. There are some screenshots I hope it useful:

mcl:

Ashlie_1-1683596690610.pngAshlie_2-1683596709919.png

uart rx:

Ashlie_3-1683596756221.png

Ashlie_4-1683596779978.png

Uart Tx is almost the same as the uart Rx.

Emmmm, I just remember something else. When I use the tx function, it didn't work until I modified a line of code as the follow:

Ashlie_5-1683597154645.png

I‘m looking forward to relpy.

Thanks.

0 Kudos
Reply

2,294 Views
Ashlie
Contributor III
About the Tx's problem, I found that there's nowhere that could enable the shifter's transmit mode in the code. So I modified the shifter's initialization configuration, and then it worked.
0 Kudos
Reply

2,286 Views
Ashlie
Contributor III
Another thing is that I set SIRC as the clock source, and the clock frequency is 4MHz.
0 Kudos
Reply

2,236 Views
cuongnguyenphu
NXP Employee
NXP Employee

Hi @Ashlie ,
Sorry for lately feedback, I've checked your configuration and still have 2 doubts for your issue:
1. As the first issue you described about the way to use Uart_AsyncReceive( 3, &test_rx_data_u8g, 1);, So I can understand that you were using PC to send Tx messages to S32K1 right? but if you config Async to receive 1 byte of the message, how did you program your application to receive the 2nd and other backward characters?

2. Why you need to modify Flexio_Uart_Ip_ConfigureTx() as it set FLEXIO_SHIFTER_MODE_TRANSMIT by default in our release source code?

0 Kudos
Reply

2,230 Views
Ashlie
Contributor III

Hi @cuongnguyenphu ,

1, I've  defined "test_uart_rx_isr" as the rx_call_back func, and the usage is as the picture:

Ashlie_0-1684139515041.png

Each byte is processed in the func "test_rev_isr" which means that I would process the rx byte every time it came in by the event "UART_EVENT_RX_FULL",

and then started the next rx at the time of "UART_EVENT_END_TRANSFER".

 

2. I guess maybe there was some kind of accident or something else when generating configuration code by EB tresos which resulted in that I didn't get FLEXIO_SHIFTER_MODE_TRANSMIT in the Flexio_Uart_Ip_ConfigureTx(). That was set disable. At first time I didn't know what happened and why there was no  one byte transmited. After I read almost all the code for flexio uart function in MCL, I considered maybe I should try to modified it, and then I got it. It's really a painful experience...

0 Kudos
Reply

2,212 Views
cuongnguyenphu
NXP Employee
NXP Employee

Hi @Ashlie ,
I created and have a quick test with the same Baudrate and Uart source clock as you configured in your project. There's only 1 thing that I used UART_1 to receive msg from PC to my S32K144 board (I don't have board to setup FlexIO communicate with PC)
And I didn't see messy character with this Baudrate happened. I've also changed nothing in RTD resource file. So could you check my attached project to see the issue still happens from your side?
My example will receive input from PC via Uart_1 and store message until user press Enter button.
 

cuongnguyenphu_0-1684318961690.png

cuongnguyenphu_1-1684318994835.png



 

 

0 Kudos
Reply

2,208 Views
Ashlie
Contributor III

Hi @cuongnguyenphu ,

I thought you didn't really understand me. It was because I configured the flexio module instead of any uart module as a channel, I got wrong data. I've used UART0, UART1 and UART2(these 3 modules all work well), so I had to use the flexio to configure the fourth uart function.

Maybe I should fill in some details.

1. The number of rx data I got is always less than the number of tx data from PC. For example, if PC sent 0x0a 0x0b 0x0c 0x0d 0x0e, I might get 0x0a 0x0c 0x0e or might be 0x0a 0x0c 0xNN. 

2. If I set the number of dealing with rx data is 2 or more, I would get the right 1st, 2nd data, then missing the 3rd data. It's very regular.

0 Kudos
Reply

2,192 Views
cuongnguyenphu
NXP Employee
NXP Employee

Hi @Ashlie ,
Your behavior with FlexIO is normal, because that FlexIO is using Shifter and Timer to receive data. 
If your message is continuously, at the time Shifter and Timer are disabled by Flexio_Uart_Ip_StopTransfer(), 2nd byte comes then FlexIO cannot receive it.

cuongnguyenphu_0-1684568306637.png


But LpUart is different, as in Lpuart it has Data buffer to hold data incoming. So when Interrupt of 1st byte is in progress, 2nd byte would be store in Data buffer, and Lpuart wouldn't miss it. 

cuongnguyenphu_1-1684568737100.png

My suggestion to use Uart_AsyncReceive for both instance Lpuart and FlexIO is specify BufferSize to be received. Then you will not miss characters like your behavior.

 

0 Kudos
Reply