Programming FRDM-K64F with Keil

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

Programming FRDM-K64F with Keil

Jump to solution
2,031 Views
vuklesi
Contributor I

I have recently started working with MQX 4.2 on K64F. I use Keil uVision 5 to build my application on top of the IEEE 1588 demo project. I need a very tightly timed position control for which I use the PIT module (1ms period), however, installing a regular ISR gave me a relatively large activation jitter. I found instructions on how to use a kernel ISR instead (I had to recompile MQX with MQX_ROM_VECTORS set to 0). The jitter in activation time of the ISR reduced greatly, but now the board is acting differently.

When I compile/load my project with:
_int_install_isr (INT_PIT0, PIT_IRQHandler, 0);

everything is OK, and I can reset the board multiple times and see the same code running every time.

When I compile/load my project with:

_int_install_kernel_isr (INT_PIT0, PIT_IRQHandler);

after the load finishes, I restart the board and the code runs. However, if I restart the board, no code is being run anymore until I perform another load.

Does anyone have an idea why this is happening and how to overcome this? I would really have to use kernel ISRs for my application.

Thank you very much.

0 Kudos
Reply
1 Solution
1,557 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Vuk:

I don't understand "after the load finishes, I restart the board and the code runs. However, if I restart the board, no code is being run anymore until I perform another load.".  Do you mean the code can't run if restart the board?  you need to perform another load ?If this is the case, I think it is a normal behavior,  because the vector table is in RAM, the stored information is lost if power is removed.

_int_install_kernel_isr can be used only if the vectors are in RAM. You can also install the user kernel_isr when MQX_ROM_VECTORS is set, but then you cann't use the _int_install_kernel_isr function, you need to modify the ROM vector table itself, as it resides in the flash in this configuration

mqx/source/bsp/frdmk64f/vectors.c

You can have a try, hope it helps.

Regards

Daniel

View solution in original post

0 Kudos
Reply
9 Replies
1,558 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Vuk:

I don't understand "after the load finishes, I restart the board and the code runs. However, if I restart the board, no code is being run anymore until I perform another load.".  Do you mean the code can't run if restart the board?  you need to perform another load ?If this is the case, I think it is a normal behavior,  because the vector table is in RAM, the stored information is lost if power is removed.

_int_install_kernel_isr can be used only if the vectors are in RAM. You can also install the user kernel_isr when MQX_ROM_VECTORS is set, but then you cann't use the _int_install_kernel_isr function, you need to modify the ROM vector table itself, as it resides in the flash in this configuration

mqx/source/bsp/frdmk64f/vectors.c

You can have a try, hope it helps.

Regards

Daniel

0 Kudos
Reply
1,557 Views
vuklesi
Contributor I

Hello Daniel,

Thank you very much for a prompt response. I was not aware that MQX_ROM_VECTORS set to 0 will not allow the created binary file to be runnable anytime.

Could you point me to any documents to help with customizing the vector table?

Thank you very much!

0 Kudos
Reply
1,557 Views
danielchen
NXP TechSupport
NXP TechSupport

I have a short question, do you load your image to SRAM, or to Flash ?  If you load to SRAM, I think the vector table will lost after reboot.

Regards

Daniel

0 Kudos
Reply
1,557 Views
vuklesi
Contributor I

Daniel,

I am still having trouble with this. So, I have modified the vector table in vector.c as in these screenshots:

Capture1.PNGCapture.PNG

Additionally, in one of the single-shot tasks, I call:

_int_install_kernel_isr (INT_PIT0, interpolationPeriodRoutine);
_bsp_int_init ((IRQInterruptIndex)INT_PIT0, 0, 0, TRUE);

But this does not give me the ability to run my application after restarting the board. If I remove the call to _int_install_kernel_isr, and leave only _bsp_int_initthen my ISR never gets activated, which makes me think that I am not modifying the vector table correctly. I should probably note that I do rebuild MQX projects after changing anything in the vector.c file. Could you please point out what am I doing wrong?

Thank you very much for your help.

0 Kudos
Reply
1,557 Views
danielchen
NXP TechSupport
NXP TechSupport

Here attached my code.

Regards

Daniel

0 Kudos
Reply
1,557 Views
vuklesi
Contributor I

Daniel,

Thank you very much for your efforts. I have the default vector table and I used to have several tasks that initialize the peripherals that I need. When I converged all that code into one task, even though nothing significant was really changed, my problem got fixed somehow. So, just putting all initialization into one task fixed my issue. I am not sure why this is the case, but this solved the issue.

Thank you for helping around this issue.

0 Kudos
Reply
1,557 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Vuk Lesi:

Sorry for the late response.

I double checked your questions.  I have some doubts about your results. The _int_install_kernel_isr can work well if I reboot the devices. Why your result is fail after reboot?   _int_install_kernel_isr can be used only if the vectors are in RAM. You need to place this code in user_config.h and rebuild the bsp and psp libraries.

#define MQX_ROM_VECTORS          0  

Though the vector is in RAM, it will disappear after power lost, it will reinstall the kernel isr to RAM after reboot. Sorry maybe I didn't explain it clearly in my last reply.

I did a quick test with _int_install_kernel_isr on TWR-K60D100M board, and the result is OK. I attached my code.

Regards

Daniel

0 Kudos
Reply
1,557 Views
vuklesi
Contributor I

Daniel,

Thank you very much for your help. I use the fromelf image converter to produce a .bin file at the end of building my project, which I copy to the flash memory of K64F.

Thank you for the screenshot. I suppose I should supply the name of my ISR for ivINT_PIT0, not ivINT_Hard_Fault. However, I also need to set the NVIC correctly, besides manually changing the vector table, right? I have tried just calling _bsp_int_init((IRQInterruptIndex)INT_PIT0,1,0,TRUE); but that does not work. Could you please explain what else do I need to do besides defining my ISR and adding its name to the vector table?

Thank you very much for your time.

0 Kudos
Reply
1,557 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi

Please refer to the below code

pastedImage_1.png

Regards

Daniel

0 Kudos
Reply