FRDM-K22F uart receive interrupts?

cancel
Showing results for 
Search instead for 
Did you mean: 

FRDM-K22F uart receive interrupts?

1,921 Views
christophertsch
Contributor III

I am trying to get a uart receive interrupt to work using KDS 2.0.0 and KSDK 1.1.0. I created a "hello world" KSDK/Processor Export application and tried to put the interrupt manager calls below to cause my function to be called (RecvCharISR). The UART is working because I call "debug_printf" in main() and it sends the text to my terminal emulator program. What am I missing?

 

   /* Write your code here */

  INT_SYS_InstallHandler(UART1_RX_TX_IRQn, RecvCharISR);

  INT_SYS_EnableIRQ(UART1_RX_TX_IRQn);

Labels (1)
8 Replies

362 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Christopher,

Regarding your question, I do not know where is the INT_SYS_InstallHandler(UART1_RX_TX_IRQn, RecvCharISR);. If you want to use UART based on interrupt mode, it is okay to call UART_DRV_SendData() or UART_DRV_ReceiveData() rather than UART_DRV_SendDataBlocking(), the UART_DRV_SendDataBlocking() function uses polling mode, UART_DRV_SendData() function uses interrupt mode.

I develop an example for UART based on "Hell World" example in SDK, pls refer to it.

Pls refer to the Hello World" example located at:

C:\Freescale\KSDK_1.0.0\demos\hello_world\kds\frdmk22f120m

change the hello_world.c as the attached. The hello_world.c is  located at:C:\Freescale\KSDK_1.0.0\demos\hello_world\src


BR

XiangJun Rong

362 Views
christophertsch
Contributor III

Hi XiangJun,

I appreciate your input but I am confused by your hello_world.c. You have code associating the function pit_callback with the PIT timer inside of the USE_STDIO_FUNCTIONS ifdef but then you added the non-blocking UART_DRV_Send and UART_DRV_ReceiveData to the else to the section not inside of the USE_STDIO_FUNCTIONS. Shouldn't they all be together? Should I define USE_STDIO_FUNCTIONS?

Thanks!

0 Kudos

362 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Christopher,

I am sorry for the confusion. Because another customer asked PIT question based on SDK, so I developed the code to test PIT, it is useless for you, you can remove the code of PIT  and GPIO modules.

Note that the UART_DRV_SendData() and UART_DRV_ReceiveData() api functions use interrupt mode, when you call the function, after every char has been transferred or received,the UART_DRV_IRQHandler() will be entered automatically.

Hope it can help you

BR

XiangJun Rong

0 Kudos

362 Views
pidgeydoyle
Contributor II

Hey, sorry to resurrect an old post but I was wondering if I could get a little more information on using the UART_DRV_ReceiveData() function.

As above, this is an interrupt driven routine. In my understanding using UART with Interrupts is designed to reduce the load in the processor however to use this function there seems to be a requirement to run the UART_DRV_ReceiveData() function and then wait for the receive to complete which seems quite processor intensive.

How would I go about modifying this so the interrupt will fire without having to call UART_DRV_ReceiveData() on every execution of the while loop?

Thanks

P

362 Views
basanta79
Contributor I

Hi Peter.

I'm starting with a FRDM K22F and i have the same issue.

May be in this months you found an answer to this question.

Regards

0 Kudos

362 Views
asfarley
Contributor IV

Bump, having the same issue. 

I have a periodic timer loop generating a medium-priority interrupt. Inside the function, I do a UART transmit, short delay, then recieve. When I check the recieved data, the GetCharsInRxBuf function returns 0. If I repeatedly wait until the next execution of my timer loop, I can see that the RX buffer is actually filling up, it just doesn't change status inside the periodic timer function. Here's pseudocode:

void LoggingTimer() {

TransmitPing();

Wait_ms(30);

GetResponse(&buffer);

}

If I call my periodic function outside of interrupt context (in application startup), the RX buffer recieves incoming bytes immediately after transmitting which seems to indicate that this is an interrupt-related issue. 

The UART in question is set to high-priority, so it should be able to recieve if a byte comes in during the logging function. 

Any ideas what is going on here?

**Edit**

I am using a K22F in KDS with Processor Expert, not using the SDK.

0 Kudos

362 Views
asfarley
Contributor IV

Welll, this is a bit strange. The UART RX is working inside an interrupt now. I believe all I did was change the timed interrupt to low-priority and set the UART RX/TX interrupts back to medium-priority. I don't see why this should be any different than the case where the UART is high-priority and the timer is medium-priority.

0 Kudos

362 Views
asfarley
Contributor IV

Nope, I was wrong - the issue is still occurring. Medium-priority UART interrupts (RX/TX) don't seem to happen inside a low-priority timer interrupt function. 

In my previous comment, the code seemed to be working beause it was seeing the ping and response from the previous cycle. If the RX buffer is properly cleared at the start of the timer function, it doesn't see any response.

****Edit*****

My mistake. I had a critical section wrapping my low-priority interrupt function which was blocking the UART interrupts. After putting the UART poll outside the CS, everything works fine. 

0 Kudos