Why does the IntEEPROM bean use twice the amount of memory?

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

Why does the IntEEPROM bean use twice the amount of memory?

ソリューションへジャンプ
1,622件の閲覧回数
AndersJ
Contributor IV

I use the IntEEPROM bean, and its SetByte and SetLong methods.

SetByte writes to word aligned adresses.

SetLong writes on 8 byte boundaries.

 

This means I need to allocate (with the "Used size" property)

twice the amount of memory than I intend to use.

 

Assuming my description above is correct:

* Why is the bean implemented like this?

* Where is this documented?

 

Anders J

 

ラベル(1)
タグ(1)
0 件の賞賛
1 解決策
1,327件の閲覧回数
ProcessorExpert
Senior Contributor III

Hello,

 

It  think it is rather misunderstanding. You don’t need to allocate twice amount of the memory in case of using SetByte, SetLong methods.

 

SetByte allows write each byte

SetLong allows write on four byte aligned addresses

 

For more details please see the "Address align" section in the help of the component (right click on the component -> Help command)

 

In case you want to avoid the align limitation, you can use “virtual page” feature which uses an array in RAM that could by handled and write to the flash by corresponding page methods. Please see the "Virtual page" section in the help for more details.

 

best regards
Vojtech Filip
Processor Expert Support Team

 

元の投稿で解決策を見る

0 件の賞賛
6 返答(返信)
1,327件の閲覧回数
ProcessorExpert
Senior Contributor III

Hello,

 

could you please specify what MCU do you use?

 

best regards
Vojtech Filip
Processor Expert Support Team

0 件の賞賛
1,327件の閲覧回数
AndersJ
Contributor IV

Sorry for being unclear.

It is the MC9S12XEP100, CW 4.7 and PE 2.99.

Anders J

 

 

 

0 件の賞賛
1,328件の閲覧回数
ProcessorExpert
Senior Contributor III

Hello,

 

It  think it is rather misunderstanding. You don’t need to allocate twice amount of the memory in case of using SetByte, SetLong methods.

 

SetByte allows write each byte

SetLong allows write on four byte aligned addresses

 

For more details please see the "Address align" section in the help of the component (right click on the component -> Help command)

 

In case you want to avoid the align limitation, you can use “virtual page” feature which uses an array in RAM that could by handled and write to the flash by corresponding page methods. Please see the "Virtual page" section in the help for more details.

 

best regards
Vojtech Filip
Processor Expert Support Team

 

0 件の賞賛
1,327件の閲覧回数
AndersJ
Contributor IV

Vojtech, thanks for replying.

 

I do not believe the help explains this.

Reading hte PE-generated code for SetByte I see word alignment checks.

suggesting that the code does as I claim it does, in other words,

it writes bytes to word aligned adresses.

My original questions therefore remain unanswered.

 

Could it be my code together with the PrExp_EEPROM_TAdress type definition?

 

Please see my attached code below.

The code seems to loose its formatting when include here so

I am attaching it as well, hoping to preserve the indentaions.

 

When disassembled it seems my ID parameter is doubled before adding

to PrExp_EEPROM_AREA_START.

 

BR,

Anders J

 

/*** ===================================================================** Store a byte in volatile storage defined by passed Id** If byte is already stored do not overwrite**     Parameters  : Non volatile storage parameter Id: nvsidXyz**                   Byte to store**     Returns     : nothing** ===================================================================*/void App_Driver_NonVolatileStorage_Put_uChar(unsigned char Id, unsigned char B){  PrExp_EEPROM_TAddress Location_Main, Location_Mirr;      <<<------------- POSSIBLE PROBLEM typdef ???  unsigned char WrResult;    if (Id <= nvsidEndOfStorage_uChar) // Cannot test on start, compiler complains COND always TRUE     {            if (App_Driver_NonVolatileStorage_Get_uChar(Id) != B)        {                        Location_Main = PrExp_EEPROM_AREA_START + Id;  / <<<------------- POSSIBLE PROBLEM CODE ???          Location_Mirr = Location_Main + nvsMirrorLocation;          WrResult = PrExp_EEPROM_SetByte(Location_Main, B); // Main storage          if (WrResult != ERR_OK)            {              App_Driver_Uart_TransmitStr("NVRAM write error-Main 08", TRUE);            }          WrResult = PrExp_EEPROM_SetByte(Location_Mirr, (B ^ 0xFF)); // Mirrored storage          if (WrResult != ERR_OK)            {              App_Driver_Uart_TransmitStr("NVRAM write error-Mirror 08", TRUE);            }        }    }}

 

0 件の賞賛
1,327件の閲覧回数
MarkP_
Contributor V

Hi,

Maybe type cast will help:

Location_Main = (PrExp_EEPROM_TAddress) ((unsigned char*) PrExp_EEPROM_AREA_START + Id);

~Mark

1,327件の閲覧回数
ProcessorExpert
Senior Contributor III

Hello,

 

as wrote Mark, this is not PEx issue, this is rather applicaiton issue. However this is not first time when we received such issue so we have added constants representing only numbers (e.g.IEE2_AREA_START_INT) to avoid confusion with pointer arythmetics.

 

example of HEADER of component: #define IEE2_AREA_START_INT 0x00100000UL

 

user MAIN: IEE1_SetByte((IEE1_TAddress)(IEE2_AREA_START_INT + 1),0x44);

 

CW V5.1

http://cache.freescale.com/lgfiles/devsuites/HC12/CW_HC12_v5.1_SPECIAL.exe?fpsp=1&WT_TYPE=IDE%20-%20...

 

latest PEx for CW HCS12(X) for CW V5.1: http://cache.freescale.com/lgfiles/updates/CWHC12/CW12_V5_1_PE_V3_04_SP.exe

 

best regards
Vojtech Filip
Processor Expert Support Team