cancel
Showing results for 
Search instead for 
Did you mean: 

writing data to flashmemory causes progrm crash

ezanen9
Associate II
Posted on September 13, 2006 at 09:02

writing data to flashmemory causes progrm crash

7 REPLIES 7
ezanen9
Associate II
Posted on September 06, 2006 at 11:41

Dear all,

I am using the STR715 and I have the following problem.

In debug mode I run the program from SRAM. If I use the following code:

void Write_flash(int iNummer, int iWaarde)

{

signed int iOffset =0;

unsigned int iBacklight =0;

switch(iNummer)

{

case 4: //Offset

iOffset = iWaarde;

iBacklight =*((unsigned int *)(0x400C0054));

break;

case 5: //Backlight colour setting

iOffset =*((unsigned int *)(0x400C0050));

iBacklight = iWaarde;

break;

}

/*Write all temperary variables to the flash*/

FLASH_Init();

FLASH_WritePrConfig (FLASH_B1F0,DISABLE);

FLASH_SectorErase (FLASH_B1F0);

FLASH_WordWrite (0x400C0050,iOffset);

FLASH_WordWrite (0x400C0054,iBacklight);

//FLASH_WritePrConfig (FLASH_B1F0,ENABLE);

}

And call it with: Write_flash(5,4);

There is no problem. The number 4 is written in the flash memory adress 0x400C0054(in data memory flash). I checked this by looking in the flashmemory at the specific adress via my JTAG.

However if I run my program from flash(production versions)the program crashes/stop running when the above function is called.

I don't have any idea what to problem might be. I there someone who can help me?

Thanks,

Jimmey

ezanen9
Associate II
Posted on September 06, 2006 at 12:18

Hi,

I want to write to nullbank 1 sector 0. The text in your reply is referring to bank 0. Isn't it?

Best Regard,

Jimmey

ezanen9
Associate II
Posted on September 06, 2006 at 13:39

Hi,

Thanks for the answer. Where should I put this function in my code? I think:

FLASH_Init();

FLASH_WritePrConfig (FLASH_B1F0,DISABLE);

FLASH_SectorErase (FLASH_B1F0);

FLASH_WaitForLastTask();

FLASH_WordWrite (0x400C0050,iOffset);

FLASH_WordWrite (0x400C0054,iBacklight);

FLASH_WritePrConfig (FLASH_B1F0,ENABLE);

Right?

I am working with uVision 3 from KEIL. I don't know how to execute this function from the RAM. Do you? My main program is running from flash.

Can you perhaps tell me the real problem or send me(a link to) a document?

This because I still don't know the real problem here.

regards,

Jimmey

ezanen9
Associate II
Posted on September 07, 2006 at 11:52

Hi,

Thanks! The write to flash function is being executed now. I made the following flash_function execute from SRAM:

void FLASH_Init(void) __ram

void FLASH_WritePrConfig(u32 Xsectors, FunctionalState NewState) __ram

void FLASH_WaitForLastTask(void) __ram

However the program crashes after executing the above functions.

If I run:

XTI_LineConfig(XTI_Line3, DISABLE); // runs fine

XTI_LineConfig(XTI_Line2, DISABLE); // runs fine

Write_flash(2, ADCsample); // runs fine

//program crash

Set_Display(); // not being executed

Function_update &= 0xFFFB; // not being executed

The functions in the Write_flash(2, ADCsample); function are being executed in SRAM. This works now. But the program does not return from the functions in the SRAM, it crashes. So the Set_Display(); Function_update &= 0xFFFB; are never being executed.

Does someone know what is going wrong?

Regards,

Jimmey

heribert
Associate II
Posted on September 07, 2006 at 14:34

Hello,

im my case i can write only once to the flash (address 0x400C3FFC). For a new write to the address i has to delete the sector (i use RFLASHER).

I use the routine ''FLASH_WordWrite (DownloadFlag, *(unsigned int *) FlashBuffer);'' Also i used the __ramfunc option. But it works only once.

Has anyone a idea? Thanks Heriebrt

________________

Attachments :

neu-1.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtGu&d=%2Fa%2F0X0000000aKw%2FSttp5x0i9i26qtlivgNJ8otSLZv0Lbckm4bTmWHSrdU&asPdf=false
ezanen9
Associate II
Posted on September 12, 2006 at 13:17

Hi all,

My program is still crashing. I am also using the ADC, XTI and the TIM1 interrupts.

Should I also put these interrupts in RAM, or should I disable them?

If so, should I also disable the EIC_IRQConfig(DISABLE);?

Regards,

Jimmey

ezanen9
Associate II
Posted on September 13, 2006 at 06:11

Hi,

I can not find the CPSR register in the documentation.

Can you tell me in which document I can find it? Or can you give me the adress and register discription.

Thanks,

Jimmey