K40 execute code from flash

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

K40 execute code from flash

Jump to solution
2,387 Views
royw
Contributor II

Hi,

I am new on Kinetis and IAR .

Now I wrote a liitle program with IAR EWB 6.3 for my Kinetis K40 Tower.

I can execute my progam by debugging with my JLink debugger, but when I will start my program after a Power off -> on, the program will not start.

I have already tried many ICF files but none file works.

What is wrong in my source ?

I have attached my project. May be someone can help.

Thanks in advance ..

RW

 

0 Kudos
Reply
1 Solution
1,921 Views
royw
Contributor II

I found my mistake .

 

now I can run my program from flash.

It was a wrong setting in the project options  ...

 

under General options / library Configuration -> stdout/stderr must be set to "Via SWO" .

 

Thanks for all they want help

 

 

View solution in original post

0 Kudos
Reply
11 Replies
1,921 Views
evgenik
Contributor IV

Hi.

 

I had the same problem. I added wait() for 0.25 second after MCU initialization and before all peripheries initialization. The time that you need for delay you can try by yourself.

 

Evgeni.

R&D Engineer

0 Kudos
Reply
1,921 Views
royw
Contributor II

Thanks for your fast reply, but that was not the reason ...

 

:smileysad:

0 Kudos
Reply
1,921 Views
royw
Contributor II

Can nobody help me ? :smileysad:

0 Kudos
Reply
1,921 Views
mjbcswitzerland
Specialist V

Hi

 

See pages 30/31 of the following http://www.utasker.com/docs/KINETIS/uTaskerV1.4_Kinetis_demo.pdf "Reset and Watchdog"

Maybe that will explain a possible difficulty.

 

Regards

 

Mark

 

0 Kudos
Reply
1,921 Views
royw
Contributor II

Hi,

 

in debugging mode all works fine, but it does not work when I will start the firmware without debugger.

 

RW 

0 Kudos
Reply
1,921 Views
royw
Contributor II

hmm,

 

can somebody try it on your own K40 tower ?

 

RW

0 Kudos
Reply
1,921 Views
c0170
Senior Contributor III

Hi royw,

 

i run your example,  your project does not have correctly set up the start up code. It should start with crt0.s and jump to the start().

 

If you check start function, first step is to disable wdog then call sysinit. Your problem was to disable wdog : wdog_disable();

 

Then it runs even after power reset.

 

Regards,

MartinK

0 Kudos
Reply
1,921 Views
royw
Contributor II

Hi Martin,

 

I don't understand what you mean.

In my project is the "crt0.s" implemented and the start() function call the wdog_disable();  as first. (start.c) .

 

I can set a breakpoint to this line ind start() and the debugger stopp at this line.

0 Kudos
Reply
1,921 Views
c0170
Senior Contributor III

why do you call function sysinit from main function?

 

I downloaded your project and I set breakpoint to the startup code. it did not jump there . Therefore quickly i called wdog_disable() and sysinit() from main. then everything worked after power on reset.

 

0 Kudos
Reply
1,921 Views
royw
Contributor II

I have made a smaller project with blinking LEDs.

(.zip file attached)

 

Can somebody test it on your own K40-tower.

 

With JLinks debugger I can Start and debug this project.

But it don't start from self after Power on ...

 

Thanks for your help

0 Kudos
Reply
1,922 Views
royw
Contributor II

I found my mistake .

 

now I can run my program from flash.

It was a wrong setting in the project options  ...

 

under General options / library Configuration -> stdout/stderr must be set to "Via SWO" .

 

Thanks for all they want help

 

 

0 Kudos
Reply