Hard Reset on a MK60 with Processor Expert Generated Code

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

Hard Reset on a MK60 with Processor Expert Generated Code

1,322 Views
markbishop
Contributor I

I have a new board and when I go to disable the watchdog - it throws a hard reset.  This is using Processor Expert generated code.

Here is the generated startup:

void __thumb_startup(void);

__asm void __thumb_startup(void) {

  IMPORT  __init_hardware

  IMPORT  __main

  LDR     R0, =__init_hardware

  BLX     R0

  LDR     R0, =__main

  BX      R0

  ALIGN 4

}

And the rest of it:

/*lint -esym(765,__init_hardware) Disable MISRA rule (8.10) checking for symbols (__init_hardware). The function is linked to the EWL library */

/*lint -esym(765,Cpu_Interrupt) Disable MISRA rule (8.10) checking for symbols (Cpu_Interrupt). */

void __init_hardware(void)

{

  /*** !!! Here you can place your own code before PE initialization using property "User code before PE initialization" on the build options tab. !!! ***/

  /*** ### MK60FX512VLQ15 "Cpu" init code ... ***/

  /*** PE initialization code after reset ***/

  SCB_VTOR = (uint32_t)(&__vect_table); /* Set the interrupt vector table position */

  /* Disable the WDOG module */

  /* WDOG_UNLOCK: WDOGUNLOCK=0xC520 */

  WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xC520); /* Key 1 */               <--- never gets past here

  /* WDOG_UNLOCK: WDOGUNLOCK=0xD928 */

  WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xD928); /* Key 2 */

And the ISR it jumps to is:

PE_ISR(Cpu_ivINT_Hard_Fault)

{

  /* This code can be changed using the CPU bean property "Build Options / Unhandled int code" */

  /* asm (HALT) */

}

It never gets to main.

I have another project (a native Keil project) that does get past this point...I just don't know why this ISR keeps tripping....nothing has been done on the processor yet.  I can't even get to the CLK config before it halts using Processor Expert.  I can't use my native Keil project because I want to use the LDD drivers from Processor Expert.

Labels (2)
0 Kudos
6 Replies

937 Views
mjbcswitzerland
Specialist V

Hi

I think that you may be getting fooled by the watchdog behavior when debugging:

Beware that it is impossible to step the watchdog unlock sequence with the debugger and so you will never be able to step the code location that you have marked since it will cause a watchdog reset to result.

See page 33 of http://www.utasker.com/docs/KINETIS/uTaskerV1.4_Kinetis_demo.pdf for details.

The hard fault that you are seeing probably takes place at some later code location when you allow the processor to run out of reset. Usually hard fauts are very simple to resolve:

- set a break point in the hard fault handler

- let the code run until the hard fault occurs (breakpoint hit)

- ensure that the debugger is working in disassemble mode (so that it steps instrutions rather than source code lines)

- do a single step so that the hard fault interrupt is returned from

- you will now see the instruction that cause the hard fault (check the registers involved to see the address that is being read from or written to). Then check whether the address is outside of memory space or, if in a peripheral, that the peripheral is being clocked before use.

Regards

Mark

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

K60: http://www.utasker.com/kinetis/TWR-K60N512.html / http://www.utasker.com/kinetis/TWR-K60D100M.html / http://www.utasker.com/kinetis/TWR-K60F120M.html

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

937 Views
markbishop
Contributor I

Ok, so that helped a lot, but here is where it is breaking (line 0x77E):

fp_init.PNG

This is all PE code and I am not sure how to find out how to stop it.

0 Kudos

937 Views
markbishop
Contributor I

I changed my "Floating Point Hardware" to 'Not Used' and I am moving along now.

pastedImage_0.png

Thank you for the help.

0 Kudos

937 Views
markbishop
Contributor I

To use the FPU on this processor you need to do this:

SystemInit () in system_MK60F15.c

#if (__FPU_USED == 1)                   // Keil

  /* enable FPU if available and used */

  SCB->CPACR |= ((3UL << 10*2) |             /* set CP10 Full Access               */

                 (3UL << 11*2)  );           /* set CP11 Full Access               */

#endif

Version 2 – Processor Expert code:

__init_hardware() in Cpu.c

  /*** !!! Here you can place your own code after PE initialization using property "User code after PE initialization" on the build options tab. !!! ***/

//#if (__FPU_USED == 1)                   // Keil

  /* enable FPU if available and used */

  SCB_CPACR |= ((3UL << 10*2) |             /* set CP10 Full Access               */

                 (3UL << 11*2)  );           /* set CP11 Full Access               */

//#endif

0 Kudos

936 Views
mjbcswitzerland
Specialist V

Hi

I suspect that you are configuring the wrong processor type.

What chip do you actually use?

The header you have is for the K60F (with floading point unit) but the exception is due to the fact that the FPU cannot be written to.

Either your chip doesn't have an FPU or else there is something else missing that would allow it to be accessed.

Reards

Mark

0 Kudos

936 Views
markbishop
Contributor I

I am using the MK60FX512VLQ15.

0 Kudos