EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

interruptWhileErasingFlashQuestions

Started by one00100100 December 19, 2012
Three questions...
We have done some scope testing using DIO markers and it seems to indicate that the pMM

SVMHIFG interrupt will interrupt an ongoing flash erase operation. 1. Is this the

expected behavior? 2. if I make the ISR very quick as in the example below where I

check a flag and if the flag is set, I return immediately, would the flash erase

complete normally, or will flash be corrupted? (We have a capacitor sufficient to

maintain power for the duration of a single segment erase plus some.) 3. If a flash

write operation is thusly interrupted, would it complete successfully, or corrupt?

//======================================================================//======================================================================#pragma vector=SYSNMI_VECTOR
__interrupt void SysNmiISR(void)
{
switch (SYSSNIV)
{
case 0x02: // SVMLIFG
TxBuffer(" ", 40, 1);
TxBuffer("*************** SVMLIFG", 40, 1);
__no_operation();
break;

case 0x04: // SVMHIFG
// ShutdownSaveTotals();
if (usingFlashFlag != 1) // if not erasing ow writing flash
ShutdownSaveTotals(); // else return now

break;

case 0x06: // DLYLIFG
TxBuffer(" ", 40, 1);
TxBuffer("*************** DLYLIFG", 40, 1);
__no_operation();
break;
............................

Thank you for your time,
Mike Raines

Beginning Microcontrollers with the MSP430

Guys & Girls,
Sorry, I forgot to mention the chip is MSP430F5438.

Mike Raines

________________________________
From: m... [mailto:m...] On Behalf Of one00100100
Sent: Wednesday, December 19, 2012 11:44 AM
To: m...
Subject: [msp430] interruptWhileErasingFlashQuestions

Three questions...
We have done some scope testing using DIO markers and it seems to indicate that the pMM

SVMHIFG interrupt will interrupt an ongoing flash erase operation. 1. Is this the

expected behavior? 2. if I make the ISR very quick as in the example below where I

check a flag and if the flag is set, I return immediately, would the flash erase

complete normally, or will flash be corrupted? (We have a capacitor sufficient to

maintain power for the duration of a single segment erase plus some.) 3. If a flash

write operation is thusly interrupted, would it complete successfully, or corrupt?

//======================================================================//======================================================================#pragma vector=SYSNMI_VECTOR
__interrupt void SysNmiISR(void)
{
switch (SYSSNIV)
{
case 0x02: // SVMLIFG
TxBuffer(" ", 40, 1);
TxBuffer("*************** SVMLIFG", 40, 1);
__no_operation();
break;

case 0x04: // SVMHIFG
// ShutdownSaveTotals();
if (usingFlashFlag != 1) // if not erasing ow writing flash
ShutdownSaveTotals(); // else return now

break;

case 0x06: // DLYLIFG
TxBuffer(" ", 40, 1);
TxBuffer("*************** DLYLIFG", 40, 1);
__no_operation();
break;
............................

Thank you for your time,
Mike Raines



In general, you cannot run a program in flash while flashing it. The program (ISR) needs to be running in RAM. I do not know about running from one segment while flashing another.

Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Lab (417)836-3770
SPRINGFIELD, MO 65897 USA Dept (417)836-5131

In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.
________________________________________
From: m... [m...] On Behalf Of Mike Raines [m...@hofferflow.com]
Sent: Wednesday, December 19, 2012 10:48 AM
To: m...
Subject: RE: [msp430] interruptWhileErasingFlashQuestions

Guys & Girls,
Sorry, I forgot to mention the chip is MSP430F5438.

Mike Raines

________________________________
From: m... [mailto:m...] On Behalf Of one00100100
Sent: Wednesday, December 19, 2012 11:44 AM
To: m...
Subject: [msp430] interruptWhileErasingFlashQuestions

Three questions...
We have done some scope testing using DIO markers and it seems to indicate that the pMM

SVMHIFG interrupt will interrupt an ongoing flash erase operation. 1. Is this the

expected behavior? 2. if I make the ISR very quick as in the example below where I

check a flag and if the flag is set, I return immediately, would the flash erase

complete normally, or will flash be corrupted? (We have a capacitor sufficient to

maintain power for the duration of a single segment erase plus some.) 3. If a flash

write operation is thusly interrupted, would it complete successfully, or corrupt?

//======================================================================//======================================================================#pragma vector=SYSNMI_VECTOR
__interrupt void SysNmiISR(void)
{
switch (SYSSNIV)
{
case 0x02: // SVMLIFG
TxBuffer(" ", 40, 1);
TxBuffer("*************** SVMLIFG", 40, 1);
__no_operation();
break;

case 0x04: // SVMHIFG
// ShutdownSaveTotals();
if (usingFlashFlag != 1) // if not erasing ow writing flash
ShutdownSaveTotals(); // else return now

break;

case 0x06: // DLYLIFG
TxBuffer(" ", 40, 1);
TxBuffer("*************** DLYLIFG", 40, 1);
__no_operation();
break;
............................

Thank you for your time,
Mike Raines





Emmett,

Thanks for the reply. I think it is perfectly OK to fetch program instructions from flash segment X while erasing flash segment Y.
The madness that we are pursuing relates to losing power while erasing/writing. See this article:
http://cseweb.ucsd.edu/users/swanson/papers/DAC2011PowerCut.pdf

Using capacitors, we are able to ensure enough power to finish erasing/writing, but now we believe the SVMH interrupt is interrupting the erase/write operations
And we are unsure of the consequences of this happening.

Thanks again,
Mike Raines

________________________________
From: m... [mailto:m...] On Behalf Of Redd, Emmett R
Sent: Wednesday, December 19, 2012 1:26 PM
To: m...
Subject: RE: [msp430] interruptWhileErasingFlashQuestions

In general, you cannot run a program in flash while flashing it. The program (ISR) needs to be running in RAM. I do not know about running from one segment while flashing another.

Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Lab (417)836-3770
SPRINGFIELD, MO 65897 USA Dept (417)836-5131

In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.
________________________________________
From: m... [m...] On Behalf Of Mike Raines [m...@hofferflow.com]
Sent: Wednesday, December 19, 2012 10:48 AM
To: m...
Subject: RE: [msp430] interruptWhileErasingFlashQuestions

Guys & Girls,
Sorry, I forgot to mention the chip is MSP430F5438.

Mike Raines

________________________________
From: m... [mailto:m...] On Behalf Of one00100100
Sent: Wednesday, December 19, 2012 11:44 AM
To: m...
Subject: [msp430] interruptWhileErasingFlashQuestions

Three questions...
We have done some scope testing using DIO markers and it seems to indicate that the pMM

SVMHIFG interrupt will interrupt an ongoing flash erase operation. 1. Is this the

expected behavior? 2. if I make the ISR very quick as in the example below where I

check a flag and if the flag is set, I return immediately, would the flash erase

complete normally, or will flash be corrupted? (We have a capacitor sufficient to

maintain power for the duration of a single segment erase plus some.) 3. If a flash

write operation is thusly interrupted, would it complete successfully, or corrupt?

//======================================================================//======================================================================#pragma vector=SYSNMI_VECTOR
__interrupt void SysNmiISR(void)
{
switch (SYSSNIV)
{
case 0x02: // SVMLIFG
TxBuffer(" ", 40, 1);
TxBuffer("*************** SVMLIFG", 40, 1);
__no_operation();
break;

case 0x04: // SVMHIFG
// ShutdownSaveTotals();
if (usingFlashFlag != 1) // if not erasing ow writing flash
ShutdownSaveTotals(); // else return now

break;

case 0x06: // DLYLIFG
TxBuffer(" ", 40, 1);
TxBuffer("*************** DLYLIFG", 40, 1);
__no_operation();
break;
............................

Thank you for your time,
Mike Raines









If you use regulator or converter to supply Vcc, it is best to have a big capacitor at the supply side. A way to read the voltage of the supply side is very useful too.

Before you start to Erase, do (a) check the supply voltage to make sure there is enough to spare, (b) shutdown peripherals, disable all interrupts, (c) lower MCLK rate, and (d) lower core voltage.

--- In m..., Mike Raines wrote:
>
> Emmett,
>
> Thanks for the reply. I think it is perfectly OK to fetch program instructions from flash segment X while erasing flash segment Y.
> The madness that we are pursuing relates to losing power while erasing/writing. See this article:
> http://cseweb.ucsd.edu/users/swanson/papers/DAC2011PowerCut.pdf
>
> Using capacitors, we are able to ensure enough power to finish erasing/writing, but now we believe the SVMH interrupt is interrupting the erase/write operations
> And we are unsure of the consequences of this happening.
>
> Thanks again,
> Mike Raines
>
> ________________________________
> From: m... [mailto:m...] On Behalf Of Redd, Emmett R
> Sent: Wednesday, December 19, 2012 1:26 PM
> To: m...
> Subject: RE: [msp430] interruptWhileErasingFlashQuestions
>
> In general, you cannot run a program in flash while flashing it. The program (ISR) needs to be running in RAM. I do not know about running from one segment while flashing another.
>
> Emmett Redd Ph.D. mailto:EmmettRedd@...
> Professor (417)836-5221
> Department of Physics, Astronomy, and Materials Science
> Missouri State University Fax (417)836-6226
> 901 SOUTH NATIONAL Lab (417)836-3770
> SPRINGFIELD, MO 65897 USA Dept (417)836-5131
>
> In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.
> ________________________________________
> From: m... [m...] On Behalf Of Mike Raines [mraines@...]
> Sent: Wednesday, December 19, 2012 10:48 AM
> To: m...
> Subject: RE: [msp430] interruptWhileErasingFlashQuestions
>
> Guys & Girls,
> Sorry, I forgot to mention the chip is MSP430F5438.
>
> Mike Raines
>
> ________________________________
> From: m... [mailto:m...] On Behalf Of one00100100
> Sent: Wednesday, December 19, 2012 11:44 AM
> To: m...
> Subject: [msp430] interruptWhileErasingFlashQuestions
>
> Three questions...
> We have done some scope testing using DIO markers and it seems to indicate that the pMM
>
> SVMHIFG interrupt will interrupt an ongoing flash erase operation. 1. Is this the
>
> expected behavior? 2. if I make the ISR very quick as in the example below where I
>
> check a flag and if the flag is set, I return immediately, would the flash erase
>
> complete normally, or will flash be corrupted? (We have a capacitor sufficient to
>
> maintain power for the duration of a single segment erase plus some.) 3. If a flash
>
> write operation is thusly interrupted, would it complete successfully, or corrupt?
>
> //======================================================================> //======================================================================> #pragma vector=SYSNMI_VECTOR
> __interrupt void SysNmiISR(void)
> {
> switch (SYSSNIV)
> {
> case 0x02: // SVMLIFG
> TxBuffer(" ", 40, 1);
> TxBuffer("*************** SVMLIFG", 40, 1);
> __no_operation();
> break;
>
> case 0x04: // SVMHIFG
> // ShutdownSaveTotals();
> if (usingFlashFlag != 1) // if not erasing ow writing flash
> ShutdownSaveTotals(); // else return now
>
> break;
>
> case 0x06: // DLYLIFG
> TxBuffer(" ", 40, 1);
> TxBuffer("*************** DLYLIFG", 40, 1);
> __no_operation();
> break;
> ............................
>
> Thank you for your time,
> Mike Raines
>
>
>
>
>
>
>

We do it a little different. Consider this case...

We have a 1mS interrupt ALWAYS active, and the 1st thing it does is
check the voltage. It then sets a flag if we are below norm, or clears
it if it is in normal voltage range.

Writing and/or erasing flash ONLY happens when the flag states voltage
is NORMAL.

Good luck!!

From: m... [mailto:m...] On Behalf
Of old_cow_yellow
Sent: Wednesday, December 19, 2012 11:01 PM
To: m...
Subject: [msp430] Re: interruptWhileErasingFlashQuestions

If you use regulator or converter to supply Vcc, it is best to have a
big capacitor at the supply side. A way to read the voltage of the
supply side is very useful too.

Before you start to Erase, do (a) check the supply voltage to make sure
there is enough to spare, (b) shutdown peripherals, disable all
interrupts, (c) lower MCLK rate, and (d) lower core voltage.

--- In m... , Mike
Raines wrote:
>
> Emmett,
>
> Thanks for the reply. I think it is perfectly OK to fetch program
instructions from flash segment X while erasing flash segment Y.
> The madness that we are pursuing relates to losing power while
erasing/writing. See this article:
> http://cseweb.ucsd.edu/users/swanson/papers/DAC2011PowerCut.pdf
>
> Using capacitors, we are able to ensure enough power to finish
erasing/writing, but now we believe the SVMH interrupt is interrupting
the erase/write operations
> And we are unsure of the consequences of this happening.
>
> Thanks again,
> Mike Raines
>
> ________________________________
> From: m...
[mailto:m... ] On
Behalf Of Redd, Emmett R
> Sent: Wednesday, December 19, 2012 1:26 PM
> To: m...
> Subject: RE: [msp430] interruptWhileErasingFlashQuestions
>
> In general, you cannot run a program in flash while flashing it. The
program (ISR) needs to be running in RAM. I do not know about running
from one segment while flashing another.
>
> Emmett Redd Ph.D.
mailto:EmmettRedd@... >
> Professor (417)836-5221
> Department of Physics, Astronomy, and Materials Science
> Missouri State University Fax (417)836-6226
> 901 SOUTH NATIONAL Lab (417)836-3770
> SPRINGFIELD, MO 65897 USA Dept (417)836-5131
>
> In statesmanship get the formalities right, never mind about the
moralities. -- Mark Twain.
> ________________________________________
> From: m...
[m...
] On
Behalf Of Mike Raines [mraines@...]
> Sent: Wednesday, December 19, 2012 10:48 AM
> To: m...

> Subject: RE: [msp430] interruptWhileErasingFlashQuestions
>
> Guys & Girls,
> Sorry, I forgot to mention the chip is MSP430F5438.
>
> Mike Raines
>
> ________________________________
> From: m...
[mailto:m...
] On
Behalf Of one00100100
> Sent: Wednesday, December 19, 2012 11:44 AM
> To: m...

> Subject: [msp430] interruptWhileErasingFlashQuestions
>
> Three questions...
> We have done some scope testing using DIO markers and it seems to
indicate that the pMM
>
> SVMHIFG interrupt will interrupt an ongoing flash erase operation. 1.
Is this the
>
> expected behavior? 2. if I make the ISR very quick as in the example
below where I
>
> check a flag and if the flag is set, I return immediately, would the
flash erase
>
> complete normally, or will flash be corrupted? (We have a capacitor
sufficient to
>
> maintain power for the duration of a single segment erase plus some.)
3. If a flash
>
> write operation is thusly interrupted, would it complete successfully,
or corrupt?
//=====================================================================>
//=====================================================================> #pragma vector=SYSNMI_VECTOR
> __interrupt void SysNmiISR(void)
> {
> switch (SYSSNIV)
> {
> case 0x02: // SVMLIFG
> TxBuffer(" ", 40, 1);
> TxBuffer("*************** SVMLIFG", 40, 1);
> __no_operation();
> break;
>
> case 0x04: // SVMHIFG
> // ShutdownSaveTotals();
> if (usingFlashFlag != 1) // if not erasing ow writing flash
> ShutdownSaveTotals(); // else return now
>
> break;
>
> case 0x06: // DLYLIFG
> TxBuffer(" ", 40, 1);
> TxBuffer("*************** DLYLIFG", 40, 1);
> __no_operation();
> break;
> ............................
>
> Thank you for your time,
> Mike Raines
>
>
>
>


>




The 2024 Embedded Online Conference