KL03Z interrupt

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

KL03Z interrupt

Jump to solution
4,100 Views
stevengarfinkel
Contributor III

I am sure this is totally due to my inexperience but here goes.

I am using a KL03Z 8k processor in an embedded application and I cannot get the LPTMR0 interrupt (the first I am trying) to work properly.Using KDS 1.2, bare copper, interfacing to the board using a FRDM-KL03Z dev board.

Here are some code bits.  Here is the basic interrupt enable.  Lines 143 and 144 execute but when 145 executes

pastedImage_0.png

the processor goes off into unknown territory.  When I suspend operation the condition is always:

pastedImage_1.png

When I click on NVIC_Enable I see:

pastedImage_2.png

the setup for the LPTMR is for regular interrupts so I can check some inputs.  My interrupt routine is:

pastedImage_3.png

but the interrupt routine is not being executed.

If I comment out the NVIC_Enable the program executes, but off course no interrupts occur.

The warning is for a break point which I cannot seem to clear.  I have tried it using both interrupt number 28 and LPTMR0_IRQn and they both do the same thing.

It seems to me that the interrupt routine is not being identified properly so that upon interrupt things fall apart.

Any assistance would be helpful.

Also, when using the 8k processor in this configuration KDS reports that the wrong processor has been selected, even though the 8k is properly selected.  Perhaps this is due to working through the FRDM board which has a 32k part on it.

I previously tried some dev using processor expert but it appears PE cannot be used on 8k devices.

Also, I found to get the FRDM board to work properly I needed to remove an additional resistor to separate the dev interface from the processor on the FRDM board.

Thanks again.

1 Solution
3,220 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Steven,

    Ok, you don't need to share me your schematic now, your problem is caused by the NMI function, maybe you didn't disable the NMI function correctly, this NMI pin is special, so just as what I and Mark have said, you should modify the FOPT byte in the flash configuration filed, after you modify it, please generate the HEX code, and check the 0X40D, whether your NMI_DIS is correctly.

  Please disable the NMI function and check the modification at first.

Wish it helps you!

If you still have question, please contact with me!


Have a great day,
Jingjing

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

View solution in original post

0 Kudos
Reply
17 Replies
3,220 Views
stevengarfinkel
Contributor III

I loaded the project into the FRDM KL03 board and it works fine with both the main loop counter i and the lptmr counter I added incrementing.

On the target I defined the NMI pin as a GPIO output prior to enabling the interrupt with no help.

When I set the NMI (now GPIO) high the project worked with LPTMR interrupts.

Is there something I am doing wrong?  I would assume that as soon as the pin is defined as an output its NMI function would end.

Is there some code I am missing?

In all cases I am now using the KL03Z32 version.

Thanks,

0 Kudos
Reply
3,220 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Steven,

  Did you use the NMI pin as the GPIO in your own KL03 board?

  NMI is the input pin, not the output pin, and you should connect an 4.7K to 10K pullup resistor, if you connect the NMI pin to ground, your project will enter in the NMI interrupt.

  If you want to disable the NMI pin, you should disable it in the flash FOPT address:0X40D,

  Now, could you share your own KL03 board schematic to me? I need to check it, whether it is correct.

Waiting for your reply!


Have a great day,
Jingjing

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

0 Kudos
Reply
3,220 Views
stevengarfinkel
Contributor III

I could share the schematic but there is definitely no pull up.  I am using the NMI pin for another purpose, as an ADC input in the final design.  Using it as an output set high is a short term fix.

I would have assumed that when the pin mux was set for another application that the NMI function would be disabled.   Please provide me with the code I need to disable the NMI function.

Thanks,

Steve

0 Kudos
Reply
3,221 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Steven,

    Ok, you don't need to share me your schematic now, your problem is caused by the NMI function, maybe you didn't disable the NMI function correctly, this NMI pin is special, so just as what I and Mark have said, you should modify the FOPT byte in the flash configuration filed, after you modify it, please generate the HEX code, and check the 0X40D, whether your NMI_DIS is correctly.

  Please disable the NMI function and check the modification at first.

Wish it helps you!

If you still have question, please contact with me!


Have a great day,
Jingjing

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

0 Kudos
Reply
3,220 Views
stevengarfinkel
Contributor III

Thank you Jingjing, Mark and everyone else for your help.  I edited the value in the processor.s file and it worked straight away.

0 Kudos
Reply
3,220 Views
mjbcswitzerland
Specialist V

Hi

NMI is "non-maskable" so it will aready fire before you enable interrupts in case the pin is '0' at any time after reset and before reprogramming its function.

If you don't need to use the NMI you can disable its operation by setting the NMI_DIS bit in the FOPT byte of the flash configuration.

Regards

Mark

0 Kudos
Reply
3,220 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Steven Garfinkel,

    I already help you to create a KL03Z 8K LPTMR KDS barebone project, my project is based on the KDS3.0, it can works ok on my FRDM-KL03, it can enter the LPTMR interrupt:

26.jpg

For details, please refer to the attached project.

Wish it helps you!

If you still have question, please contact with me!


Have a great day,
Jingjing

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

3,220 Views
stevengarfinkel
Contributor III

Jingjing,

Thanks for the help but it still does not want to work.  I am now using a P&E micro systems multilink universal interface.

When I load your project after running from the first interrupt and suspending operation I always get:

pastedImage_1.png

If it were running correctly I would think that when I suspended operation I would either be in the interrupt service routine or in the main loop.  When I add a counter to the LPTMR interrupt routine it never increments.

I can install the code without the statement     NVIC_EnableIRQ(28); and it will load and run but of course it will not get LPTMR interrupts.  When suspended it is in the main loop.

While debugging, besides moving the cursor to a new line and hitting Ctrl R, how do you single step?

In this program, are the interrupt vectors in RAM or in Flash and where is it designated?

Thanks again.

0 Kudos
Reply
3,220 Views
stevengarfinkel
Contributor III

I loaded your project and in my embedded system it does the same thing as before.  I am wondering if it is because I am using the 8k part using the frdm -kl03z board as the PNE interface.  Perhaps it is trying to put the interrupt vectors into memory that doesn't exist.  I will make a system with the 32k part and see if it works.

Thanks

0 Kudos
Reply
3,220 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Steven,

      What do you mean about PNE interface?

    Do you use the FRDM-KL03 on board PE debug to download the code to your 8K part board?

    When you do the debugging, if the LPTMR interrupt service code can't be work, do you stop the debug, whether the code enter to any other code?

Best Regards,


Have a great day,
Jingjing

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

0 Kudos
Reply
3,220 Views
stevengarfinkel
Contributor III

I was using the FRDM-KL03 board to download code to the target board.  It worked (with the removal of R33) for downloading and debugging code until I added the LPTMR interrupt.  I realize now that the FRDM board is linked by serial number to the processor on the FRDM board and limits performance to other processors.  I am buying another programming interface to resolve the issue.

When I was using the FRDM board the performance was as I described above.  I would suspend running and it would be sitting at the default isr.  There may have been other errors due to coding that may have contributed as I was working a number of issues at the same time.

0 Kudos
Reply
3,220 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Steven,

    From your description, your problem is not caused by the LPTMRT,  it caused by the debugger, so you need to buy a seperated debugger, eg, JLINK, P&E multilink to your own board.

    After you have the new debugger, you can try my code again.

  If you still have problem at that time, you can let me know!

Best Regards,

Jingjing


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

0 Kudos
Reply
3,220 Views
mjbcswitzerland
Specialist V

Hi

How are the interrupt vectors set up; to run in SRAM or directly from Flash? Practically, due to the very small SRAM size in the KL03, location in Flash is the only one that is really practical.

Check that your vectors have a LPTMR entry since otherwise it will try to take the interrupt and jump to 0xffffffff (and of course fail).

If you have problems with KDS or PE not supporting the part fully or you generally prefer a much more efficient solution see:

http://www.utasker.com/kinetis/FRDM-KL03Z.html

which gives you complete project operation and (approx.) real time KL03/board simulation to allow project testing and debugging without any HW debugging constrains or guesswork.

Regards

Mark

3,220 Views
stevengarfinkel
Contributor III

Mark,

Thanks and I think you are on the right track.  I have looked over the information on interrupts but I did not see anything about setting the interrupt vectors.  Since my program runs to ff..ff9 I am guessing there was no interrupt vector.

I assumed that by naming the interrupt handler LPTMR0_IRQHandler that the compiler set the vector but I am guessing that there is more to it than that.  I would like to understand this so if you could give me some guidance I would appreciate it.  This will be the first of a series of interrupts I will need.

So more questions:  How do I set the interrupt vectors to be in Flash?

Thanks again.

0 Kudos
Reply
3,219 Views
mjbcswitzerland
Specialist V

Steven

Probabyl you have some assmebler files in your projet that include the reset and interrupt vectors that are located at the start of Flash. You will need to locates these and then see whether the have entries for the interrupts that you required.

Below is the const vector from the uTasker KL03 project, where is is done in C code - the LPTMR entry can be seen (there is no reason for assembler in a Kinetis project...)

const _RESET_VECTOR __attribute__((section(".vectors"))) reset_vect

= {

    (void *)(RAM_START_ADDRESS + (SIZE_OF_RAM - NON_INITIALISED_RAM_SIZE)), // stack pointer to top of RAM

    (void (*)(void))START_CODE,                                          // start address

    irq_NMI,

    irq_hard_fault,

    irq_memory_man,

    irq_bus_fault,

    irq_usage_fault,

    0,

    0,

    0,

    0,

    irq_SVCall,

    irq_debug_monitor,

    0,

    irq_pend_sv,

    _RealTimeInterrupt1,                                                 // systick

    {                                                                    // processor specific interrupts

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    _wakeup_isr,

    _IIC_Interrupt_0,

    irq_default,

    irq_default,

    irq_default,

    _LPSCI0_Interrupt,                                                   // LPUART 0

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    _rtc_alarm_handler,

    _rtc_handler,

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    irq_default,

    _RealTimeInterrupt2,       // LPTMR interrupt

    irq_default,

    _port_A_isr,

    _port_B_isr

    }

};

The VTOR (vector table offset register) can be left at its default 0x00000000 when operating directly in Flash.

There is nothing else to be done.

Regards

Mark

3,220 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Steven,

Please check whether you enable the LPTMR interrupt through the register of LPTMRx_CSR->TIE,

and the check whether the interrupt occur through the TCF :

pastedImage_0.png

if the two points are right , you can send your project to me , i will check it on my side.


Have a great day,
Alice Yang

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

3,220 Views
stevengarfinkel
Contributor III

I have TIE enabled.  Thanks.

0 Kudos
Reply