How to start executing program on K64F right after power on

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

How to start executing program on K64F right after power on

Jump to solution
5,579 Views
quevedo
Contributor V

Hello,

I am using a FRDM-K64F board in a project, and I am facing a problem. I want my board to start executing the program already flashed into the Targer CPU (K64) right after I power on the board. However, the program only starts after I press the RESET button. I am powering the board through a smartphone charger with micro USB plug, and I have tried both USB connectors (SDA and MCU). When I power the board with the SDA USB connector, I need to use RESET button, and when I power it with the K64 USB connector, not even RESET works. Also, I tried both Segger OpenSDA2 and mbed apps loaded on the OpenSDA controller, and results do not change.

I need to use one of the 2 USB connectors to power the board; I do not want to use the 3V3 or 5-9V power input pins on J3. My question is: should I cut some jumper trace, and solder jumper pins? Maybe change some of the already installed jumper setting?

Thanks,

Labels (1)
Tags (3)
1 Solution
4,252 Views
BlackNight
NXP Employee
NXP Employee

Hi Antonio,

the far most easiest way is to use Processor Expert: here you can easily disable the EzPort:

pastedImage_0.png

Erich

View solution in original post

0 Kudos
Reply
17 Replies
4,252 Views
BlackNight
NXP Employee
NXP Employee

Hi Antonio,

I think you see the problem related to the NMI pin, related to the EzPort.

The issue has been discussed (with the solution) in details here:

FRDM-K64F booting issue when powered from USB port

I hope this helps,

Erich

0 Kudos
Reply
4,252 Views
quevedo
Contributor V

Hello, Erich,

Thanks for your prompt reply. i have read the other post about NMI issues, and I intend to write a small program to clear EZPORT_DIS bit at FOPT Flash register, so I do no have to make any hardware changes. If that does not work, I will simply remove C55, which is much easier than placing R75.

Now, my question is: is there any post where I can find a step-by-step sequence to write the FOPT register, preferrably using KDS 3.0?

Thanks again,

Antonio

0 Kudos
Reply
4,253 Views
BlackNight
NXP Employee
NXP Employee

Hi Antonio,

the far most easiest way is to use Processor Expert: here you can easily disable the EzPort:

pastedImage_0.png

Erich

0 Kudos
Reply
4,252 Views
leonardobueno
Contributor I

Erich,

I am having the same problem with the NMI/EZP_CS pin, when the equipment starts it gets stuck depending on the state of the pin. However, I am not using the FRDM_K64F. I built a prototype on top of the K64F design, and the NMI/EZP_CS pin was supposed to be used as an interruption. There is also a very important differentiation on my project. It has separated regions for bootloader and application.

This is the memory region for application:

pastedImage_0.png

This is the memory region for the bootloader

pastedImage_1.png

I tried to use the solution sugested on FRDM-K64F booting issue when powered from USB port on both bootloader and application, but it didn't work.

pastedImage_4.png

I just checked the binary file generated by the KDS, and it is clear that the Flash_Config region has the configuration set. But its seems like something is cleaning the configuration or the processor is reading the wrong memory space. When I verify on Debugging the value of the FOPT register saved on memory it is still FF.

I also tried to generate the PE code and use it on the code. It also failed.

Is there any thing else I can try?

0 Kudos
Reply
4,252 Views
mjbcswitzerland
Specialist V

Leonardo

Beware that your boot loader code dictates the behavior and not the values you have in your application.

Your application can completely remove its m_flash_config region since it has no affect.

It is best to read back the values from flash (0x400..0x40f) rather than look in the binary file. This is what is "really" in the Flash after programming.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html

K64: http://www.utasker.com/kinetis/FRDM-K64F.html / http://www.utasker.com/kinetis/TWR-K64F120M.html / http://www.utasker.com/kinetis/TWR-K65F180M.html

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos
Reply
4,252 Views
leonardobueno
Contributor I

Well, I did verified the value of the register when debugging. This value is the actual saved on flash, I suppose. As show bellow, the FOPT register is written with 0xFF. I can also check FSEC, and it is what it was supposed to be (0xFE).

pastedImage_0.png

pastedImage_1.png

0 Kudos
Reply
4,252 Views
mjbcswitzerland
Specialist V

Leonardo

What values do you see in Flash at 0x400?

This is what I read from my FRDM-K64F, when configured to disable EzPort and NMI:

0x00000400

00 00 00 00 00 00 00 00 ff ff ff ff be 01 ff ff  ................

When I read FOPT and FSEC registers they are the same:

0x40020002 be 01  ..

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html

K64: http://www.utasker.com/kinetis/FRDM-K64F.html / http://www.utasker.com/kinetis/TWR-K64F120M.html / http://www.utasker.com/kinetis/TWR-K65F180M.html

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos
Reply
4,252 Views
leonardobueno
Contributor I

Mark,

This is what is written on the memory location 0x400:

pastedImage_0.png

It was supposed to be FFFFFFFF FFFFFFFF FFFFFFFF FFFFFDFE

Regards

Leonardo

0 Kudos
Reply
4,252 Views
leonardobueno
Contributor I

Mark

When I try to flash the bootloader, the console gives me:

Warn : Any changes to flash configuration field will not take effect until next reset

Warn : Requested write to flash configuration field 0xffffffff 0xffffffff 0xffffffff 0xfffffdfe transformed to 0xffffffff 0xffffffff 0xffffffff 0xfffffffe

What is making it act like this?

Leonardo

0 Kudos
Reply
4,252 Views
mjbcswitzerland
Specialist V

Leonardo

That is an issue (or setting) with your debugger.

You will have to contact the manufacturer to find out why.

I load using the OpenSDA's drag-and-drop function, which doesn't restrict the flash configuration programming..

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html

K64: http://www.utasker.com/kinetis/FRDM-K64F.html / http://www.utasker.com/kinetis/TWR-K64F120M.html / http://www.utasker.com/kinetis/TWR-K65F180M.html

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos
Reply
4,252 Views
leonardobueno
Contributor I

Mark,

I used the drag and drop function of the OenOCD Debugger. Now I see the memory location 0x400 was modified for the desired value, but... I still doens´t work. The uC still blocks on reset depending on the state of the pin.

Any other ideas?

Leonardo

0 Kudos
Reply
4,250 Views
mjbcswitzerland
Specialist V

Leonardo

You are setting 0xfd as the FOPT value - this means that you have disabled EzPort mode but not NMI pin operation.

If the pin is '0' at reset it will immediately jump to the NMI handler.

If you have no handler it will immediately fail.

From user's manual:

pastedImage_4.png

Therefore, if you need to use the NMI as interrupt input (in which case your setting would be OK) you MUST install an NMI handler in the vector table in Flash. This handler WILL immediately be called and it must clear the interrupt and then it can return and let the start-up procedure continue.

If you don't need NMI operation later you can disable it by writing the FOPT to 0x01.

If you search the forum you will find other discussions of handling the NMI at reset.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html

K64: http://www.utasker.com/kinetis/FRDM-K64F.html / http://www.utasker.com/kinetis/TWR-K64F120M.html / http://www.utasker.com/kinetis/TWR-K65F180M.html

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos
Reply
4,250 Views
leonardobueno
Contributor I

Mark,

As shown bellow, I did what you said and saved 0xF9 on the FOPT Register instead of 0xFD. This way, both the NMI and the EZPort are disabled. It worked wonderfully. Thank you for your help.

pastedImage_0.png

Leonardo Bueno

0 Kudos
Reply
4,250 Views
quevedo
Contributor V

Thanks! That just did the job!

0 Kudos
Reply
4,252 Views
mjbcswitzerland
Specialist V

Antonio

The issue that you are having is due to the NMI line on the FRDM-K64F. There is quite a large capacitor connected to it so the input is held low for some time after powering on the board, which causes the processor to start in EzPort mode.

This can be avoided by configuring the device to disable EzPort and also default the input to GPIO (rather than NMI, which would then also require a default NMI handler to be installed in Flash).

This means that you need to correctly configure the non-volatile option in the Flash configuration area (byte at address 0x40b).

The following is the standard setting for the FRDM-K64F in the uTasker project which allows problem-free power-up operation:

#define KINETIS_FLASH_CONFIGURATION_NONVOL_OPTION  (FTFL_FOPT_EZPORT_DISABLED | FTFL_FOPT_LPBOOT_NORMAL | FTFL_FOPT_NMI_DISABLED) // there is a large capacitor on the NMI/EzP_CS input so these are disabled to allow it to start without requiring an NMI handler or moving to EzPort mode

Regards

Mark

P.S. It may look strange that I have answered 'after' you have already sorted the issue out but I did post it earlier but my contributions are moderated by Freescale and so at the weekend they can get delayed quite a bit. Possibly the moderator could delete this one and explain how I could possibly get off the moderation list....? If not, please remove the INBOX watch and add the EMAIL watch each time it is approved since the INBOX watch is very annoying.

Kinetis: µTasker Kinetis support

K64: µTasker Kinetis FRDM-K64F support  / µTasker Kinetis TWR-K64F120M support  / µTasker Kinetis TWR-K65F180M support

For the complete "out-of-the-box" Kinetis experience and faster time to market

4,252 Views
bobpaddock
Senior Contributor III

I believe the issue is the links in your signature.

Messages without links post without moderation.

Mark Butcher:

I did post it earlier but my contributions are moderated by Freescale and so at the weekend they can get delayed quite a bit. Possibly the moderator could delete this one and explain how I could possibly get off the moderation list....?

0 Kudos
Reply
4,252 Views
mjbcswitzerland
Specialist V

Bob

Thanks - that is what is happening.

I am having some delayed by a day - also in the week - so will avoid external links whenever possible.

Regards

Mark

0 Kudos
Reply