kl04 reset

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

kl04 reset

Jump to solution
1,493 Views
davidsun
Contributor II

this is the first time I use this Freescale chip, I feel the reset is very tricky.

I download this code to the chip, I guess it is successful.

with FRDM-02z, the reset is high. but after I power cycle and removed FRDM-02z the reset become strange, don't understand why, if my board have problem or some setup is wrong. the yellow trace is the reset signal

need help from who has gone through this problem

appreciate your help.

this is the program

/* ###################################################################

**     Filename    : ProcessorExpert.c

**     Project     : ProcessorExpert

**     Processor   : MKL04Z32VFK4

**     Version     : Driver 01.01

**     Compiler    : IAR ARM C Compiler

**     Date/Time   : 2014-05-09, 17:06, # CodeGen: 0

**     Abstract    :

**         Main module.

**         This module contains user's application code.

**     Settings    :

**     Contents    :

**         No public methods

**

** ###################################################################*/

/*!

** @file ProcessorExpert.c

** @version 01.01

** @brief

**         Main module.

**         This module contains user's application code.

*/      

/*!

**  @addtogroup ProcessorExpert_module ProcessorExpert module documentation

**  @{

*/      

/* MODULE ProcessorExpert */

/* Including needed modules to compile this module/procedure */

#include "Cpu.h"

#include "Events.h"

#include "GPIO1.h"

/* Including shared modules, which are used for whole project */

#include "PE_Types.h"

#include "PE_Error.h"

#include "PE_Const.h"

#include "IO_Map.h"

/* User includes (#include below this line is not maintained by Processor Expert) */

LDD_TDeviceData *MyGPIO1Ptr;

/*lint -save  -e970 Disable MISRA rule (6.3) checking. */

int main(void)

/*lint -restore Enable MISRA rule (6.3) checking. */

{

  /* Write your local variable definition here */

    unsigned int i,j;

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

  PE_low_level_init();

  /*** End of Processor Expert internal initialization.                    ***/

  MyGPIO1Ptr = GPIO1_Init((LDD_TUserData *)NULL);

  /* Write your code here */

  /* For example: for(;;) { } */

  for(;;)

  {

    for(j=0;j<10;j++)for(i=0;i<65535;i++);

    GPIO1_ToggleFieldBits(MyGPIO1Ptr, RED, 0x1U);

  }

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/

  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/

  #ifdef PEX_RTOS_START

    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */

  #endif

  /*** End of RTOS startup code.  ***/

  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/

  for(;;){}

  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END ProcessorExpert */

/*!

** @}

*/

/*

** ###################################################################

**

**     This file was created by Processor Expert 10.4 [05.06]

**     for the Freescale Kinetis series of microcontrollers.

**

** ###################################################################

*/

this is debug log

Fri May 09, 2014 08:46:13: Windows NT detected.

Fri May 09, 2014 08:46:14: OpenSDA detected - Flash Version 1.05

Fri May 09, 2014 08:46:14: Device is KINETIS.

Fri May 09, 2014 08:46:14: Mode is In-Circuit Debug.

Fri May 09, 2014 08:46:14: CPU reset by debugger.

Fri May 09, 2014 08:46:14:

Fri May 09, 2014 08:46:14: Software reset was performed

Fri May 09, 2014 08:46:14: 936 bytes downloaded (11.72 Kbytes/sec)

Fri May 09, 2014 08:46:14: Loaded debugee: C:\Users\dsun\Downloads\KL04_TEST_24\Debug\Exe\KL04_TEST_24.out

Fri May 09, 2014 08:46:15: CPU reset by debugger.

Fri May 09, 2014 08:46:15:

Fri May 09, 2014 08:46:15: Software reset was performed

Fri May 09, 2014 08:46:15: Target reset MAP001.BMP.bmp

Labels (1)
Tags (1)
0 Kudos
1 Solution
1,025 Views
mjbcswitzerland
Specialist V

Hi David

This looks quite random and so probably has no real meaning (possibly the project that you have doesn't set this up correctly and so it is just random code?).

If it had a meaning it would be as explained in section 27.3.1 of the KL04 reference manual. Specifically the backdoor comparison keys would be

01 10 06 E6 4E 06 E7 4E

Various Flash sectors would be protected due to

10 00 00 0B

The Flash security would be defined by

16 (backdoor key access disabled; mass erase enabled; Freescale factory access denied; MCU security status is unsecured)

The options would be defined by

00 (low power boot, NMI disabled, RESET pin disabled)

and

03 08 have no meaning.

If the values are random it is worth working out why and setting safe values because, in the worst case, certain values could secure your chip and block futher erase operation and so render it unusable for further work.

What I have done is attach a reference binary file. This is for the FRDM-KL05 board but is probably suitable for your KL04 too (with 32.768kHz oscillator) and the processor runs at 47.97235MHz (it has a UART menu on UART0, drives PWM outputs and timer interrupts and also reads the on-board accelerometer at 400Hz, with the measurements optionally displayed on the UART - depending on menu settings). The processor is using DMA for memory movement and also for the UART transmission. The important thing for you is the binary content showing the flash configuration setup (0x400..0x40f) for comparison:

00 00 00 00 00 00 00 00 ff ff ff ff be 08 ff ff (note that the 08 configures the RESET function on the RESET pin).

Note that the uTasker project at µTasker Kinetis support and its code at KINETIS Project Code contains KL support (runs on all devices from KL02 to K70), including simulation of the device so you may prefer to start with a fully operational project in case your goals are to develop applications rather than to learn and debug each part of the device.

Regards

Mark

View solution in original post

0 Kudos
8 Replies
1,025 Views
mjbcswitzerland
Specialist V

Hi

Check how the RESTET pin is configured by RESET_PIN_CFG in FTFA_FOPT.

This is controlled by a bit setting in configuration FLASH (0x400..0x0f). Look at the binary file that is generated to see what is set there and then work out where this can be configured in the SW in case it is not as desired.

Regards

Mark

1,025 Views
davidsun
Contributor II

Hi Mark

thank you very much for your prompt response, but I am new to this chip and tools. could you please write a little more detail. look at where in binary file?

thank you,

David

0 Kudos
1,025 Views
mjbcswitzerland
Specialist V

David

Open the binary file in a binary editor and see what the 16 byte values are form the address 0x400..0x40f. These are the flash configuration values that the chip reads in each times it starts - one of these bist controls the reset pin function (either as reset pin or as GPIO)

Regards

Mark

1,025 Views
davidsun
Contributor II

I checked .out file, at address 400 to 40f are

01 10 06 E6 4E 06 E7 4E 10 00 00 0B 16 00 03 08

could you please tell how to explain these values. which document explain this values.

thanks

David

0 Kudos
1,026 Views
mjbcswitzerland
Specialist V

Hi David

This looks quite random and so probably has no real meaning (possibly the project that you have doesn't set this up correctly and so it is just random code?).

If it had a meaning it would be as explained in section 27.3.1 of the KL04 reference manual. Specifically the backdoor comparison keys would be

01 10 06 E6 4E 06 E7 4E

Various Flash sectors would be protected due to

10 00 00 0B

The Flash security would be defined by

16 (backdoor key access disabled; mass erase enabled; Freescale factory access denied; MCU security status is unsecured)

The options would be defined by

00 (low power boot, NMI disabled, RESET pin disabled)

and

03 08 have no meaning.

If the values are random it is worth working out why and setting safe values because, in the worst case, certain values could secure your chip and block futher erase operation and so render it unusable for further work.

What I have done is attach a reference binary file. This is for the FRDM-KL05 board but is probably suitable for your KL04 too (with 32.768kHz oscillator) and the processor runs at 47.97235MHz (it has a UART menu on UART0, drives PWM outputs and timer interrupts and also reads the on-board accelerometer at 400Hz, with the measurements optionally displayed on the UART - depending on menu settings). The processor is using DMA for memory movement and also for the UART transmission. The important thing for you is the binary content showing the flash configuration setup (0x400..0x40f) for comparison:

00 00 00 00 00 00 00 00 ff ff ff ff be 08 ff ff (note that the 08 configures the RESET function on the RESET pin).

Note that the uTasker project at µTasker Kinetis support and its code at KINETIS Project Code contains KL support (runs on all devices from KL02 to K70), including simulation of the device so you may prefer to start with a fully operational project in case your goals are to develop applications rather than to learn and debug each part of the device.

Regards

Mark

0 Kudos
1,025 Views
davidsun
Contributor II

I only have a FRDM-02Z demo board, but after rework I believe it can work for my on board. IAR didn't complain, but the result is not correct so far. all my knowledge about IAR and PE is a Freescale training class, I roughly now how to generate simply project and code. is it possible to load a bin file to my board, by FRDM-02Z. if it could please send me a link to user manual. I put a Kinetis chip on my board for future use, but I really don't want spend too much time on it now.

thanks,

David

0 Kudos
1,025 Views
mjbcswitzerland
Specialist V

David

If I understand correctly you are using a FRDM-KL02 board as debugger to a KL04 (that is you have connected the SWD lines from the K20 on the FRDM-KL02 to the SWD lines of the KL04 on the other boards). It sounds as though the debugger is basically working.

The FRDM-KL02 board appears as an external hard-drive to the PC that it is connected to and a binary image can be loaded by simply dragging and dropping it to this hard drive. Thsi will program the binary image to the processor that it is connected to.

You can also use IAR to "connect" to the board rather than downloading to the board and use its register view to read register content.

Regards

Mark

0 Kudos
1,025 Views
davidsun
Contributor II

Hi Mark

Freescale support help me generated a program and now I can load the code and see the pin toggle waveform.  but he or she don't know how to set the chip in deep sleep. here is my code, it not work. could you please give me some hint.

/* ###################################################################

**     Filename    : ProcessorExpert.c

**     Project     : ProcessorExpert

**     Processor   : MKL04Z8VFK4

**     Version     : Driver 01.01

**     Compiler    : IAR ARM C Compiler

**     Date/Time   : 2014-05-27, 10:23, # CodeGen: 0

**     Abstract    :

**         Main module.

**         This module contains user's application code.

**     Settings    :

**     Contents    :

**         No public methods

**

** ###################################################################*/

/*!

** @file ProcessorExpert.c

** @version 01.01

** @brief

**         Main module.

**         This module contains user's application code.

*/        

/*!

**  @addtogroup ProcessorExpert_module ProcessorExpert module documentation

**  @{

*/        

/* MODULE ProcessorExpert */

/* Including needed modules to compile this module/procedure */

#include "Cpu.h"

#include "Events.h"

#include "GPIO1.h"

/* Including shared modules, which are used for whole project */

#include "PE_Types.h"

#include "PE_Error.h"

#include "PE_Const.h"

#include "IO_Map.h"

//#include "llwu.h"

/* User includes (#include below this line is not maintained by Processor Expert) */

LDD_TDeviceData *MyGPIO1Ptr;

/*lint -save  -e970 Disable MISRA rule (6.3) checking. */

int main(void)

/*lint -restore Enable MISRA rule (6.3) checking. */

{

  /* Write your local variable definition here */

    unsigned int i,j, k;

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

  PE_low_level_init();

  /*** End of Processor Expert internal initialization.                    ***/

  MyGPIO1Ptr = GPIO1_Init((LDD_TUserData *)NULL);

  /* Write your code here */

  /* For example: for(;;) { } */

  PORTB_PCR6 |= PORT_PCR_MUX(0x01);

  PORTB_PCR6 |= 0x03;

  GPIOB_PDDR |= 0X40;

 

  for(k=0;k<10;k++)

  {

    for(j=0;j<2;j++)for(i=0;i<6553;i++);

   GPIO1_ToggleFieldBits(MyGPIO1Ptr, PTB3, 0x1U);                            // this code works

   GPIOB_PTOR |= 0x40;

      //GPIOB_PTOR |= 0x40;

  }

  // the following 4 lines is I copied from low power demo program provide by Freescale. I don't know what this means, all I need to do is put the chip in sleep mode and I may use them later.

     PORTA_PCR7 = PORT_PCR_MUX(1);      //p3

//     llwu_configure(1<<3, LLWU_PIN_RISING, 0);

       SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;   

      SMC_PMCTRL = SMC_PMCTRL_STOPM(4);     

      SMC_STOPCTRL = SMC_PMCTRL_STOPM(0) | SMC_STOPCTRL_PORPO_MASK;  // disable POR circuit 

     

       for(k=0;k<10;k++)

  {

    for(j=0;j<2;j++)for(i=0;i<655;i++);

   GPIO1_ToggleFieldBits(MyGPIO1Ptr, PTB3, 0x1U);                     // I still can see the signal toggle, which is not expected. I hope the chip in sleep mode

   GPIOB_PTOR |= 0x40;

      //GPIOB_PTOR |= 0x40;

  }

//        printf("\n enter into VLLS0_2 mode--.\n");

//      SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;   

//      SMC_PMCTRL = SMC_PMCTRL_STOPM(4);     

//      SMC_STOPCTRL = SMC_PMCTRL_STOPM(0) | SMC_STOPCTRL_PORPO_MASK;  // disable POR circuit 

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/

  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/

  #ifdef PEX_RTOS_START

    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */

  #endif

  /*** End of RTOS startup code.  ***/

  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/

  for(;;){}

  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END ProcessorExpert */

/*!

** @}

*/

0 Kudos