Strange behaviour of Safe Routine for writting flash

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

Strange behaviour of Safe Routine for writting flash

3,917 Views
cabl
Contributor III

Hi everybody,

I´m using a 56F82646 part and having some trouble with the PE´s IntFlash component. To my understanding there´s something odd in the PE code for the SafeRoutineCaller:

- when stack location where SaveRoutineStackSpace is placed is under 0x7FF (RAM address), SafeRoutineInDataPtr gets a value under 0xFFF (double of SaveRoutineStackSpace address), and SafeRoutineInCodePtr=0xF000 + SafeRoutineInDataPtr is a valid address under 0xFFFF and everything works fine. At least this es what I can see in the debugger.

- when stack location where SaveRoutineStackSpace is placed is over 0x7FF, SafeRoutineInDataPtr gets a value over 0xFFF and SafeRoutineInCodePtr=0xF000 + SafeRoutineInDataPtr is a INVALID address (over 0xFFFF). Now it does not work.

If I force SaveRoutineStackSpace to be global and be placed at low RAM addresses it always work fine, without any other change in the code, just the SaveRoutineStackSpace position.

This behaviour seems to be independent of the memory model and width of the pointer used in the project options.

Am I not understanding something here? 

Thanks in advance.

0 Kudos
Reply
7 Replies

3,883 Views
cabl
Contributor III

Thanks for the response! I did know that. But the problem is I can´t see any warning or protection in the PE IntFlash component code that protects against invalid address when there is high stack usage. How should this code be modified to force word access?

Thanks

0 Kudos
Reply

3,877 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Pls try to use large data model rather than small data model to avoid the issue.

BR

XiangJun Rong

0 Kudos
Reply

3,823 Views
cabl
Contributor III

No luck, sorry. The large memory model still fails when executing SafeRoutineCaller if stack usage is high. 

0 Kudos
Reply

3,795 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I have reviewed your code, but I do not see the code to erase flash, if you program flash space which are not erased, you may damage the flash.

How about using the code:

/*!
** @file main.c
** @version 01.16
** @brief
** Main module.
** This module contains user's application code.
*/
/*!
** @addtogroup main_module main module documentation
** @{
*/
/* MODULE main */


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "Pins1.h"
#include "IFsh1.h"
#include "IntFlashLdd1.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 "Init_Config.h"
#include "PDD_Includes.h"

#define PROADDRESS 0x7000

unsigned int array[1024];
unsigned int temp,i;
unsigned int *pointer;

void main(void)
{
/* Write your local variable definition here */

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/

/* Write your code here */
/* Write your code here */
for(i=0;i<1024;i++)
{
array[i]=i;
}
pointer=(unsigned int *)PROADDRESS;
//erase program flash from address:0x1 F000
IFsh1_EraseSector((unsigned long)PROADDRESS);
pointer=(unsigned int *)PROADDRESS;
asm(nop);
for(i=0; i<1024; i++)
{
IFsh1_SetWordFlash((unsigned long)pointer,array[i]);
pointer++;
}
for(;;) {}
}

/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.3 [05.09]
** for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/

BR

XiangJun Rong

0 Kudos
Reply

3,724 Views
cabl
Contributor III

Hi!

The erasure of the sector is done automatically by the PE component if needed, no problem with this (option safe write with erase).

Have you been able to test IFsh1_SetWordFlash function when stack usage is high? 

Regards,

 

0 Kudos
Reply

3,369 Views
cabl
Contributor III

No chance of testing the "bug" (or my missinterpretation) in IFsh1_SetWordFlash?

0 Kudos
Reply

3,893 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

As the following screenshot in MCU_DSC_Compiler.pdf, if you use byte access in the application code and in small model, the address must be less than 0x7FFF.

The MCU_DSC_Compiler.pdf is located

......\Freescale\CW MCU v11.1\MCU\Help\PDF

xiangjun_rong_0-1640229513184.png

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply