Using UART FIFO buffer in K22

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

Using UART FIFO buffer in K22

2,139 Views
vaibhavi_padwal
Contributor II

Hi,

I am using custom board using MK22FX512AVLQ12. I want to use FIFO buffer in UART communication to reduce the number of interrupts I get.

I want to get an interrupt of (UART1) only after 8 packets of data are received. If there are less than 8 packets received I don't want to have an interrupt, instead I'll read that data after a specific time has elapsed (implementing timer using FTM).

I noticed that irrespective of the RX FIFO WaterMark, I always get the interrupt no. of packets received are equal to size of the receiver buffer whose pointer I pass as *xfer in following function:

status_t UART_TransferReceiveNonBlocking(UART_Type *base, uart_handle_t *handle,  uart_transfer_t *xfer, size_t *receivedBytes)

Moreover, if I set the size of receiver buffer as 8 bytes and in case the data received is more than 8 packets I get an interrupt and read 8 packets of data. But I don't know how to read the remaining data packets once the my timer has elapsed. Please find the source code attached.

There are no example codes for the controller I am using in MCUXpresso. So I tried finding example codes of similar controller only using FIFO buffer triggering. But did not found an example code that will help me in understanding the issue.

Please help in resolving the issue. An example code that uses FIFO buffer based interrupts in K22 series would be of great help.

Thanks & Regards,

Vaibhavi P

Labels (1)
0 Kudos
Reply
3 Replies

2,095 Views
vaibhavi_padwal
Contributor II

Hi,

I used FIFO buffer for UART1 with help of Rx Data buffer full Interrupt (kUART_RxDataRegFullInterruptEnable).

But now I only get the interrupt when number of data is equal to RXWaterMark. So in order to not miss any data, I also try to read the RX buffer of UART after a certain timeout. Everything works correctly if the baudrate of my RS485 utility matches with controller UART baudrate.

But in case I switch the baud rate of my utility to incorrect baudrate for some time and then again switch it back to correct baud rate, I get no response from the controller unless I soft restart the controller. As per my knowledge I have correctly handled all the error flags and cleared them as well.

Please help in resolving this issue.

I have attached the code files below.

Thanks & Regards,

Vaibhavi P

Tags (2)
0 Kudos
Reply

2,034 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi

There is an idle line detection feature in Kinetis MCU.

When a frame of data is sent, the idle detection function will detect from the stop bit of the last data. When the10th or  the13th consecutive high levels are detected, it means that the data of the previous frame has been transmitted. At this time, UART generates an idle line interrupt, in which a data frame reception completion flag can be set, Then the main program can process the received data

UARTx_S1 :

danielchen_0-1630394522423.png

 

0 Kudos
Reply

2,137 Views
ErichStyger
Senior Contributor V

Hi @vaibhavi_padwal ,

You might have a look at my code for the K02 (this is a stripped down K22, e.g. no USB) which uses the FIFO for RS-485 communication:

https://github.com/ErichStyger/MetaClockClock/blob/main/Firmware/ClockCommon/rs485Uart.c

It is using MCUXpresso IDE and SDK.

I hope this example helps,

Erich

0 Kudos
Reply