D flash memory read after reset ( without enabled emulated eeprom)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

D flash memory read after reset ( without enabled emulated eeprom)

831件の閲覧回数
rubykrishna
Contributor III

We are using MC9S12XEP100 family. It has emulated eeprom feature, However we are not using it, we used to store eeprom data in d flash ( traditional approach) without using  emulated eeprom  buffer ram.

 

On start up,

 

_starup()

{

main()

}

 

main()

{

uint8 c;

clock_init();

flash_init();

  c=*(uint8* __far)0x100000 (i.e 0x100000 start address of the d flash memory) 

}

 

Lets us consider that i have value 23 in the following address 0x100000'G

Wen i tried to read that value, i couldn't read it. It's reading it as c=0.

 

 

So i modified the code as such 

main()

{

uint8 c;

clock_init();

flash_init();

delay(5ms);

  c=*(uint8* __far)0x100000 (i.e 0x100000 start address of the d flash memory) 

}

 

Wen i kept a delay 5 ms it reading the value  at 100000 c=23

 

Please help me ! Is any delay required after reset for reading a d flash memory. I didn't find  these case in other micro controllers.

ラベル(1)
3 返答(返信)

627件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hi Ruby,

I am not aware of any necessary delay for reading D-Flash.

Unfortunately, I was not able to reproduce described issue.

 

Is _startup() function first function executed after reset (like _Startup() function in standard project)?

If yes, I cannot see stack initialization command in your code.

For example: INIT_SP_FROM_STARTUP_DESC();

The same is valid for zero out and copy down functions like standard Init(); function.

 

I created very simple code in main.c file:

 

#include <hidef.h>      /* common defines and macros */

#include "derivative.h"      /* derivative-specific definitions */

 

const unsigned char mydata @0x000800 = 0x23;

 

void main(void) {

  volatile unsigned char c;

  c=*(unsigned char * __far)0x100000;

DDRA = 0x01;

  if (c == 0x23) PORTA = 0x01;

    else PORTA = 0x00;

  for(;;) {

  } /* loop forever */

}

Additionally I placed “mydata” name into ENTRIES section in prm file because mydata is not directly referenced in the code and I want avoid to optimizing it out.

 

The c variable is loaded correctly despite on fact whether main() is called after or before Init() function.

 

If the variable c is declared inside main() function, it will be created on the stack.

If the variable c is declared as the global variable, it will be created on RAM.

 

This leads me to question how did you test variable c value and how you signalize it?

When the variable is on the stack, there may be some problem with address position or stack pointer modifying.

When you use BDM for reading variable c value, the BDM communication needs some time for reading it and 0 may be just initial value before getting first value.

 

 

Could you please specify your MCU by part number and maskset?

I tested P9S12XET256MAL with maskset 1M53J running on 16MHz crystal.

The MCU was not partitioned (DFPART,ERPART=0xFF)

 

If you send me your project, I may shortly check it for any obvious or potential issues.

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

627件の閲覧回数
rubykrishna
Contributor III

Hi Sastek,

Thanks for your response.

 

I tried ur above code. Its working at that context.

Our controller is MC9S12XET256 (MC9S12XEP100 family) with bus clock 24 MHz external oscillator 4MHz.

As the fact, im not using any partition command( not using emulated eeprom).

 

But the problem i observed is after writing to eeprom location in Runtime. Please write the same 0x23 @ 10_0000'G in run time using D flash command ( FCCOB,FCCOBIX registers). I verified that the value is stored in eeprom ( memory window). I did battery reset, checked the value again, its reading as '0'. However its working in Debugger reset.

 

if put a delay of 5ms  in start up() and then reading value stored in the eeprom. Its read as 0x23. Its working in all ranges.

 

 

Please help me in deciphering the issue!!

0 件の賞賛

627件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hi Ruby,

Thank you for more details.

Could you please specify content of your clock_init(); and flash_init(); functions?

 

We cannot simultaneously read D-Flash and execute any flash command on the same flash block.

I guess that this may be a reason of incorrect reading from D-Flash.

 

You may try to comment out these functions or read D-Flash address prior these functions.

For example:

main()

{

uint8 c;

c=*(uint8* __far)0x100000

clock_init();

flash_init();

}

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛