What do I need to get the LPUART IRQ Handler to work for the FRDM-MKL82Z

cancel
Showing results for 
Search instead for 
Did you mean: 

What do I need to get the LPUART IRQ Handler to work for the FRDM-MKL82Z

Jump to solution
185 Views
Contributor II

I am developing a project in MCUXpresso for the FRDM-MKL82Z board with the SDK for that board from NXP. There is an 'lpuart_interrupt' example project included in the SDK that I am using as a reference to use UART with the interrupt functionality. I did some messing around with the example and everything worked fine. Then, I went to create a new project through the new project wizard, which is a C++ project rather than C. I copied and pasted the contents of the main source file from the example into my main source file generated from the project wizard, so those files are identical. However, at first UART would not work. I realized what I had done wrong when noticing that the 'pin_mux.c' file was missing the UART pin configuration in the function 'BOARD_InitPins(void)'. I added the parts that I was missing to the 'pin_mux.c' file in my own project and only part of the program will work. It seems like TX works (through the function 'LPUART_WriteByte()') but every time data is sent to the RX pin it goes into hard fault (I figured out though the debugger). It has something to do with the LPUART_EnableInterrupts() function because the hard fault does not happen until after this is done. I assume there are some things in the drivers, board, device, or component folders that I need to change to make it work properly, but after comparing each file with the ones from the example project I cannot figure out what changes to make to make my program work. 

Has anybody else experienced this kind of issue or know how to get the LPUART interrupt to work without going into hardfault?

Thanks!

Labels (1)
Tags (1)
1 Solution
86 Views
NXP TechSupport
NXP TechSupport

Hi Ronald,

Please look at this case. He has a same problem. This is a C/C++ mixed compilation problem.

https://community.nxp.com/message/1010451?commentID=1010451#comment-1010451 

Regards,

Jing

View solution in original post

8 Replies
87 Views
NXP TechSupport
NXP TechSupport

Hi Ronald,

Please look at this case. He has a same problem. This is a C/C++ mixed compilation problem.

https://community.nxp.com/message/1010451?commentID=1010451#comment-1010451 

Regards,

Jing

View solution in original post

86 Views
Contributor II

This was definitely the issue. Thanks for your help!!

0 Kudos
86 Views
NXP TechSupport
NXP TechSupport

Hi Ronald,

But your LPUART0 interrupt service routine name is LPUART0_DriverIRQHandler. In startup_mkl82z7.cpp, the LPUART0 IRQ handler name is  LPUART0_IRQHandler in g_pfnVectors. They should keep same.

Regards,

Jing

0 Kudos
86 Views
Contributor II

I tried this as well but it still does not work. Here is the example project from the SDK for comparison. 
I would like to know also if I should have to configure the ISR through the config tools? I have the pin_mux.c correctly configured for LPUART to work, but it seems like enabling the interrupt causes problems. Is there a setting in the config tools that I am missing? I have loaded the default settings through the "New Project" wizard, but I have not changed anything through the Config Tools.

0 Kudos
86 Views
NXP TechSupport
NXP TechSupport

Hi Ronld,

There is three LPUART in KL82. I wonder if this is because the interrupt vector point to wrong IRQ handler. Please check g_pfnVectors table in startup_mkl82z7.cpp.

Regards,

Jing

0 Kudos
86 Views
Contributor II

Just checked on this- everything looks correct in this table. So I don't think this is the issue

0 Kudos
86 Views
NXP TechSupport
NXP TechSupport

Hi,

Can you share me your project here?

Regards,

Jing

0 Kudos
86 Views
Contributor II

Here is the zip file of my project. My goal is to cycle the color of the onboard RGB LED every time the interrupt occurs.

0 Kudos