Program cannot exit from UART interrupt in FRDM-K64F

cancel
Showing results for 
Search instead for 
Did you mean: 

Program cannot exit from UART interrupt in FRDM-K64F

Jump to solution
235 Views
Contributor III

Hi, my name is Leandro, and I working with MCUXpresso, Configuration Tools and my FRDM-K64F board. My problem is as follows:

I start a project with MCUXpresso and an SDK from my board to receive data using UART4 from a Bluetooth module. The data consists of a 10-byte stream that is sent from an Android device.

I wrote the following interrupt routine to receive data:

void UART4_SERIAL_RX_TX_IRQHANDLER(void)
{
        UART_ReadBlocking(UART4, data, 10);
    #if defined __CORTEX_M && (__CORTEX_M == 4U)
        __DSB();
    #endif
}

and the main function is as simple as:

int main(void) {
    BOARD_InitBootPins();
    BOARD_InitBootClocks();
    BOARD_InitBootPeripherals();
    BOARD_InitDebugConsole();

    while(1) {
        PRINTF("Hello world!\r\n");
    }
    return 0 ;
}

The problem is, when I receive some 10-bytes data packages, the program is trapped inside the interrupt, particularly in the function UART_ReadBlocking(), and never leaves there. It seems that there is some problem with RCFIFO flag.

The configuration of the UART4 is shown in the next figures:

1.png

2.png

What is the correct form to receive the 10-bytes of data using UART4??

NOTE: I attached the sample project that uses UART and interrupts, but it doesn't work either.

Thanks,

Best regards.

Labels (1)
0 Kudos
1 Solution
55 Views
NXP Employee
NXP Employee

Hello Leandro,

I'd like to confirm first that you are able to reproduce the example as is. The original example has a ring buffer of 16 bytes. There should not be a problem receiving 10 bytes, even if it does overflow it will just begin to write the ring buffer again. I have tested this example and am able to see that you can receive more than 10 bytes at a time. 

Could you please try to connect your Bluetooth module directly connected to the UART0 and see if you are getting the same results? 

The project that you have attached is not enough for me to reproduce the same behavior that you are seeing. There were many sections that are commented out, which may be the cause of flags not being set or cleared properly. If the above test does not work with UART0 with the original example, please attach your project as you are using it. With the code that you describe from your original post. 

Another test to be made is sending 10 byte data to your UART module, directly by another UART module to see if your configurations and interruptions are working properly prior to connecting the Bluetooth module. 

Also could you please provide the pins you are using to connect your Bluetooth module on the FRDM-K64?

Best Regards,

Sabina

View solution in original post

5 Replies
55 Views
NXP Employee
NXP Employee

Hello Leandro,

Hope you are doing well.

I recommend to check the examples provided in the SDK that use UART with interrupt. 

pastedImage_1.png

Please try to use this first and see if the problem persists. The readblocking function will wait until the RX register to be full or the RX fifo to have data. This means that if its not meeting one or the other then it will be stuck until it does. 

You can also attempt to use the readnonblocking function and see if you produce the same error. 

Hope it helps!

Sabina

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

----------------------------------------------------------------------------------------------------------------------- 

0 Kudos
55 Views
Contributor III

Hi Bruce, thanks for your quick response.

I tried the example you mentioned, but the problem is that I only receive the first two bytes of data from the 10-byte sequence.

I attached the sample project of the uart_interrupt, maybe you can find the error and give me some help.

Best regards.

0 Kudos
56 Views
NXP Employee
NXP Employee

Hello Leandro,

I'd like to confirm first that you are able to reproduce the example as is. The original example has a ring buffer of 16 bytes. There should not be a problem receiving 10 bytes, even if it does overflow it will just begin to write the ring buffer again. I have tested this example and am able to see that you can receive more than 10 bytes at a time. 

Could you please try to connect your Bluetooth module directly connected to the UART0 and see if you are getting the same results? 

The project that you have attached is not enough for me to reproduce the same behavior that you are seeing. There were many sections that are commented out, which may be the cause of flags not being set or cleared properly. If the above test does not work with UART0 with the original example, please attach your project as you are using it. With the code that you describe from your original post. 

Another test to be made is sending 10 byte data to your UART module, directly by another UART module to see if your configurations and interruptions are working properly prior to connecting the Bluetooth module. 

Also could you please provide the pins you are using to connect your Bluetooth module on the FRDM-K64?

Best Regards,

Sabina

View solution in original post

55 Views
Contributor III

Hi Sabina Bruce,

Sorry for my delay in responding, I am working on this project as a hobbyist and cannot spend too much time on it.

I tried the sample project you mentioned and the 10-byte data was received correctly. Then I made a copy of the functions and settings from the example in my own project and now it works fine.

I still have to do a review of my previous code to see what went wrong. When I do I will post here in case someone has the same problem as me.

Thanks a lot!

Best regards,

Leandro.

0 Kudos
55 Views
NXP Employee
NXP Employee

Hi Leandro,

I am glad everything is working well. That would be great if you could post what went wrong for future reference.

Have a great weekend!

Sabina

0 Kudos