KL04 UART interrupts not working

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

KL04 UART interrupts not working

774 Views
knex
Contributor I

I started developing a new project based on a custom board with a MKL04Z32VFK4 processor, and got stuck with a pretty basic thing. UART interrupts do not seem to work.

 

On the board I have a peripheral device, which starts sending data after detecting low state on a pin called TX_REQ, which is connected to one of the processor pins: PTA8. The KL04 uses UART0 with pins PTB1 and PTB2.

 

Using KDS 2.0.0 and Processor Expert plugin with its UART:AsynchroSerial component, I prepared two generally identical projects, the simplest as they can be, with only one difference. The first communicates with the device using no interrupts (TX_REQ to 0, some delay, and then reading the Rx register), the second uses interrupts. The first project is working fine - KL04 sets the pin to 0, the device starts sending data, the data appears in the register. The second one does not receive the data, although the data are present on the UART_RX pin (checked with the oscilloscope). The interrupt routine (automatically generated PE_ISR(ASerialLdd1_Interrupt)) is not called - at least the CPU does not stop there on a breakpoint in the debug mode. The Processor Expert settings say that the interrupts are enabled (Cpu:MKL04Z32VFK4 properties), and Interrupt service/event in the UART0 properties is also checked.

 

For sure this is no a hardware issue, because everything works fine in the project with no interrupts. The basic project settings and the code execution flow are also correct, for the same reason. The sources in these two projects differ only in automatically generated code parts, where these differences seem to be related only to some UART interrupts procedures and their enabling. So there must be something missing or incorrect with these settings, I think, but for now I have no idea what it is.

 

So my question is: what do I basically need to set in the Processor Expert, in order to start UART0 interrupts working properly?

 

I attach both of the projects, if that could help helping me.

Original Attachment has been moved to: uart-test-no-isr.zip

Original Attachment has been moved to: uart-test-isr.zip

Tags (3)
0 Kudos
2 Replies

421 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Kamil,

I checked the project of uart-test-isr, and tried it on the FRDM-KL05Z, what I did is just changing the MCU device as well as the GPIO component and comment out all the main code except PE_low_level_init().

pastedImage_1.png

pastedImage_2.png

It works well as expected. The interrupt service hits when I input some character to UART0, so the configuration should be right.

pastedImage_0.png

the problem is implementation. The interrupt mode is different from polling mode, so user should not use UART_RecvChar() directly to receive the data, instead the receiving is handled in the ISR, and the data is passed to the internal buffer -- BufferRead, and this event may be notified to main application in the callback of  ASerialLdd1_OnBlockReceived() which calls UART_OnRxChar(),

pastedImage_6.png

User should notify the main application in this function with a global flag, and then main code may use  UART_RecvChar() to get that data, to continue receiving data, the application code should wait for the flag again.

Hope that helps,


Have a great day,
Kan

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

421 Views
knex
Contributor I

Hi Kan,

Thank you for your detailed answer and clarifying hints, but it still does not work.

I was aware that using UART_RecvChar() is not precisely correct in the interrupt mode, but I was calling it after Tx request and a delay, which should be enough to receive at least one Rx interrupt - the delay is for sure long enough in the working no-interrupt project, therefore should be enough here also. So using it or not is actually negligible here.

But still, I checked it now with only PE_low_level_init() left in main(), with a simple loop toggling TX_REQ pin with a delay. The result is the same - the interrupt does not occur (I'm adding a breakpoint in the same line, as you are; debugging generally works as expected - stops on breakpoints in the main loop and so on).

0 Kudos