Yahoo Groups archive

68300

Index last updated: 2026-04-29 00:01 UTC

Thread

Disabling interrupts during Flash writing sessions

Disabling interrupts during Flash writing sessions

2003-09-14 by Marty Burns

I am debugging the flash writing routines for an embedded 68LC302
application. I seem to get some kind of bus fault? when I disable interrupts
prior to invoking a flash erase followed by interrupt enable. I think the
communications engine is in the process of transmitting and it may have a
transmitter interrupt ready when I invoke the enable interrupts code.

Does anyone have a sense that I should be doing something additional in my
entry and leaving the flash routines. Note the flash routines are located in
RAM. The rest of the code is in the FLASH. These routines involve execution
from RAM since the FLASH is not valid during erase or write.

To disable interrupts:
#define DISABLE	ASM(" ori.w #0x0700,%sr")

To enable interrups:
#define ENABLE	ASM(" andi.w #0xf8ff,%sr")

To erase flash:

void FlashErase(int sector)
{
	FLASH_PTR[0] = 0xF0F0;  // reset device to read mode

	DISABLE;

	FLASH_PTR[0x555] = 0xAAAA;			// unlock 1
	FLASH_PTR[0x2AA] = 0x5555;			// unlock 2
	FLASH_PTR[0x555] = 0x8080;
	FLASH_PTR[0x555] = 0xAAAA;
	FLASH_PTR[0x2AA] = 0x5555;
	FLASH_PTR[flashSectors[sector].offset/2] = 0x3030;
	while(FlashStatus(FLASH_PTR)!=STATUS_READY)
		TICKLE_WATCHDOG;

	ENABLE;

}


int FlashStatus(volatile WORD *fp)
{
	 unsigned char d, t;
	 int retry = 1;

again:

	 d = *fp;        /* read data */
	 t = d ^ *fp;    /* read it again and see what toggled */

	 if (t == 0) {           /* no toggles, nothing's happening */
		return STATUS_READY;
	 }
	 else if (t == 0x04) { /* erase-suspend */
		if (retry--) goto again;    /* may have been write completion */
		return STATUS_ERSUSP;
	 }
	 else if (t & 0x40) {
		if (d & 0x20) {     /* timeout */
		  return STATUS_TIMEOUT;
		}
		else {
		  return STATUS_BUSY;
		}
	 }

	 if (retry--) goto again;    /* may have been write completion */

	 return STATUS_ERROR;
}

Re: [68300] Disabling interrupts during Flash writing sessions

2003-09-16 by jeffrey.tenney@gm.com

Marty,

Do you get the mysterious fault immediately after the DISABLE command or 
immediately after the ENABLE command?

Jeff





"Marty Burns" <burnsmarty@...>
09/14/2003 02:19 PM
Please respond to 68300

 
        To:     <68300@yahoogroups.com>
        cc:     "Martin J. Burns" <burnsmarty@...>
Show quoted textHide quoted text
        Subject:        [68300] Disabling interrupts during Flash writing sessions


I am debugging the flash writing routines for an embedded 68LC302
application. I seem to get some kind of bus fault? when I disable 
interrupts
prior to invoking a flash erase followed by interrupt enable. I think the
communications engine is in the process of transmitting and it may have a
transmitter interrupt ready when I invoke the enable interrupts code.

Does anyone have a sense that I should be doing something additional in my
entry and leaving the flash routines. Note the flash routines are located 
in
RAM. The rest of the code is in the FLASH. These routines involve 
execution
from RAM since the FLASH is not valid during erase or write.

To disable interrupts:
#define DISABLE          ASM(" ori.w #0x0700,%sr")

To enable interrups:
#define ENABLE           ASM(" andi.w #0xf8ff,%sr")

To erase flash:

void FlashErase(int sector)
{
                 FLASH_PTR[0] = 0xF0F0;  // reset device to read mode

                 DISABLE;

                 FLASH_PTR[0x555] = 0xAAAA;      // unlock 1
                 FLASH_PTR[0x2AA] = 0x5555;      // unlock 2
                 FLASH_PTR[0x555] = 0x8080;
                 FLASH_PTR[0x555] = 0xAAAA;
                 FLASH_PTR[0x2AA] = 0x5555;
                 FLASH_PTR[flashSectors[sector].offset/2] = 0x3030;
                 while(FlashStatus(FLASH_PTR)!=STATUS_READY)
                                 TICKLE_WATCHDOG;

                 ENABLE;

}


int FlashStatus(volatile WORD *fp)
{
                  unsigned char d, t;
                  int retry = 1;

again:

                  d = *fp;        /* read data */
                  t = d ^ *fp;    /* read it again and see what toggled */

                  if (t == 0) {           /* no toggles, nothing's 
happening */
                                 return STATUS_READY;
                  }
                  else if (t == 0x04) { /* erase-suspend */
                                 if (retry--) goto again;    /* may have 
been write completion */
                                 return STATUS_ERSUSP;
                  }
                  else if (t & 0x40) {
                                 if (d & 0x20) {     /* timeout */
                                   return STATUS_TIMEOUT;
                                 }
                                 else {
                                   return STATUS_BUSY;
                                 }
                  }

                  if (retry--) goto again;    /* may have been write 
completion */

                  return STATUS_ERROR;
}




---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 






[Non-text portions of this message have been removed]

RE: [68300] Disabling interrupts during Flash writing sessions

2003-09-16 by Marty Burns

After the enable command.
Show quoted textHide quoted text
-----Original Message-----
From: jeffrey.tenney@... [mailto:jeffrey.tenney@...]
Sent: Monday, September 15, 2003 8:08 PM
To: 68300@yahoogroups.com
Subject: Re: [68300] Disabling interrupts during Flash writing sessions


Marty,

Do you get the mysterious fault immediately after the DISABLE command or
immediately after the ENABLE command?

Jeff





"Marty Burns" <burnsmarty@...>
09/14/2003 02:19 PM
Please respond to 68300


        To:     <68300@yahoogroups.com>
        cc:     "Martin J. Burns" <burnsmarty@...>
        Subject:        [68300] Disabling interrupts during Flash writing
sessions


I am debugging the flash writing routines for an embedded 68LC302
application. I seem to get some kind of bus fault? when I disable
interrupts
prior to invoking a flash erase followed by interrupt enable. I think the
communications engine is in the process of transmitting and it may have a
transmitter interrupt ready when I invoke the enable interrupts code.

Does anyone have a sense that I should be doing something additional in my
entry and leaving the flash routines. Note the flash routines are located
in
RAM. The rest of the code is in the FLASH. These routines involve
execution
from RAM since the FLASH is not valid during erase or write.

To disable interrupts:
#define DISABLE          ASM(" ori.w #0x0700,%sr")

To enable interrups:
#define ENABLE           ASM(" andi.w #0xf8ff,%sr")

To erase flash:

void FlashErase(int sector)
{
                 FLASH_PTR[0] = 0xF0F0;  // reset device to read mode

                 DISABLE;

                 FLASH_PTR[0x555] = 0xAAAA;      // unlock 1
                 FLASH_PTR[0x2AA] = 0x5555;      // unlock 2
                 FLASH_PTR[0x555] = 0x8080;
                 FLASH_PTR[0x555] = 0xAAAA;
                 FLASH_PTR[0x2AA] = 0x5555;
                 FLASH_PTR[flashSectors[sector].offset/2] = 0x3030;
                 while(FlashStatus(FLASH_PTR)!=STATUS_READY)
                                 TICKLE_WATCHDOG;

                 ENABLE;

}


int FlashStatus(volatile WORD *fp)
{
                  unsigned char d, t;
                  int retry = 1;

again:

                  d = *fp;        /* read data */
                  t = d ^ *fp;    /* read it again and see what toggled */

                  if (t == 0) {           /* no toggles, nothing's
happening */
                                 return STATUS_READY;
                  }
                  else if (t == 0x04) { /* erase-suspend */
                                 if (retry--) goto again;    /* may have
been write completion */
                                 return STATUS_ERSUSP;
                  }
                  else if (t & 0x40) {
                                 if (d & 0x20) {     /* timeout */
                                   return STATUS_TIMEOUT;
                                 }
                                 else {
                                   return STATUS_BUSY;
                                 }
                  }

                  if (retry--) goto again;    /* may have been write
completion */

                  return STATUS_ERROR;
}




---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/






[Non-text portions of this message have been removed]



---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

RE: [68300] Disabling interrupts during Flash writing sessions

2003-09-16 by jeffrey.tenney@gm.com

Marty,

Be sure your VBR points into RAM, meaning that your entire 
interrupt-vector table is in RAM. 

Also, be sure your ISRs are also in RAM and can execute from there.  The 
routines must be position independent or you must map the RAM to the 
"correct" address for the routines.

Jeff





"Marty Burns" <burnsmarty@...>
09/15/2003 05:48 PM
Please respond to 68300

 
        To:     <68300@yahoogroups.com>
        cc: 
Show quoted textHide quoted text
        Subject:        RE: [68300] Disabling interrupts during Flash writing sessions


After the enable command.

-----Original Message-----
From: jeffrey.tenney@... [mailto:jeffrey.tenney@...]
Sent: Monday, September 15, 2003 8:08 PM
To: 68300@yahoogroups.com
Subject: Re: [68300] Disabling interrupts during Flash writing sessions


Marty,

Do you get the mysterious fault immediately after the DISABLE command or
immediately after the ENABLE command?

Jeff





"Marty Burns" <burnsmarty@...>
09/14/2003 02:19 PM
Please respond to 68300


        To:     <68300@yahoogroups.com>
        cc:     "Martin J. Burns" <burnsmarty@...>
        Subject:        [68300] Disabling interrupts during Flash writing
sessions


I am debugging the flash writing routines for an embedded 68LC302
application. I seem to get some kind of bus fault? when I disable
interrupts
prior to invoking a flash erase followed by interrupt enable. I think the
communications engine is in the process of transmitting and it may have a
transmitter interrupt ready when I invoke the enable interrupts code.

Does anyone have a sense that I should be doing something additional in my
entry and leaving the flash routines. Note the flash routines are located
in
RAM. The rest of the code is in the FLASH. These routines involve
execution
from RAM since the FLASH is not valid during erase or write.

To disable interrupts:
#define DISABLE          ASM(" ori.w #0x0700,%sr")

To enable interrups:
#define ENABLE           ASM(" andi.w #0xf8ff,%sr")

To erase flash:

void FlashErase(int sector)
{
                 FLASH_PTR[0] = 0xF0F0;  // reset device to read mode

                 DISABLE;

                 FLASH_PTR[0x555] = 0xAAAA;      // unlock 1
                 FLASH_PTR[0x2AA] = 0x5555;      // unlock 2
                 FLASH_PTR[0x555] = 0x8080;
                 FLASH_PTR[0x555] = 0xAAAA;
                 FLASH_PTR[0x2AA] = 0x5555;
                 FLASH_PTR[flashSectors[sector].offset/2] = 0x3030;
                 while(FlashStatus(FLASH_PTR)!=STATUS_READY)
                                 TICKLE_WATCHDOG;

                 ENABLE;

}


int FlashStatus(volatile WORD *fp)
{
                  unsigned char d, t;
                  int retry = 1;

again:

                  d = *fp;        /* read data */
                  t = d ^ *fp;    /* read it again and see what toggled */

                  if (t == 0) {           /* no toggles, nothing's
happening */
                                 return STATUS_READY;
                  }
                  else if (t == 0x04) { /* erase-suspend */
                                 if (retry--) goto again;    /* may have
been write completion */
                                 return STATUS_ERSUSP;
                  }
                  else if (t & 0x40) {
                                 if (d & 0x20) {     /* timeout */
                                   return STATUS_TIMEOUT;
                                 }
                                 else {
                                   return STATUS_BUSY;
                                 }
                  }

                  if (retry--) goto again;    /* may have been write
completion */

                  return STATUS_ERROR;
}




---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/






[Non-text portions of this message have been removed]



---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 






[Non-text portions of this message have been removed]

RE: [68300] Disabling interrupts during Flash writing sessions

2003-09-16 by Melear Charles-rdph40

Hello everyone,
 
In the 683xx series (of which the 68302 is NOT a member, oddly enough) when a write is done to the CPU status register, the "edge recognition" circuit for IRQ7 is re-enabled.  What this means in English is that if the I-bits are any value at all (yep, any old value) and the IRQ7 pin is currently low  and the code is inside the IRQ7 interrupt handler and the IRQ7 line remains low at the exit (execution of an RTE instruction) a NEW IRQ7 will be recognized even though there was no high to low transition on IRQ7.
 
The IRQ7 edge detect circuit is re-enabled any time that there is a "write" to the CPU status register as well, such as one created by an ori.w #0x0700,%sr or an andi.w #0xf8ff,%sr instruction.

If the IRQ7 line is low when you enable interrupts with one of the above instructions, a new IRQ7 will be taken.  If this occurs, will it mess up your system?
 
I think that the 68302 works the same way.  Remember, the 68302 uses a 68000 core as opposed to a 68020 core.
 
 
 
 
 
 
Also, if you are getting a Bus Error, there is a lot of stuff pushed to the stake.  If you system has not gone totally to the weeks, have the Bus Error handler dump the stack contents to memory, that is, read the last 50 or so bytes on the stack.  this will give you all sorts of information about where the error occurs and what type of error it is.
 
Regards,
 
Charlie
Show quoted textHide quoted text
 -----Original Message-----
From: jeffrey.tenney@... [mailto:jeffrey.tenney@...]
Sent: Tuesday, September 16, 2003 12:58 PM
To: 68300@yahoogroups.com
Subject: RE: [68300] Disabling interrupts during Flash writing sessions



Marty,

Be sure your VBR points into RAM, meaning that your entire 
interrupt-vector table is in RAM. 

Also, be sure your ISRs are also in RAM and can execute from there.  The 
routines must be position independent or you must map the RAM to the 
"correct" address for the routines.

Jeff





"Marty Burns" <burnsmarty@...>
09/15/2003 05:48 PM
Please respond to 68300


        To:     <68300@yahoogroups.com>
        cc: 
        Subject:        RE: [68300] Disabling interrupts during Flash writing sessions


After the enable command.

-----Original Message-----
From: jeffrey.tenney@... [mailto:jeffrey.tenney@...]
Sent: Monday, September 15, 2003 8:08 PM
To: 68300@yahoogroups.com
Subject: Re: [68300] Disabling interrupts during Flash writing sessions


Marty,

Do you get the mysterious fault immediately after the DISABLE command or
immediately after the ENABLE command?

Jeff





"Marty Burns" <burnsmarty@...>
09/14/2003 02:19 PM
Please respond to 68300


        To:     <68300@yahoogroups.com>
        cc:     "Martin J. Burns" <burnsmarty@...>
        Subject:        [68300] Disabling interrupts during Flash writing
sessions


I am debugging the flash writing routines for an embedded 68LC302
application. I seem to get some kind of bus fault? when I disable
interrupts
prior to invoking a flash erase followed by interrupt enable. I think the
communications engine is in the process of transmitting and it may have a
transmitter interrupt ready when I invoke the enable interrupts code.

Does anyone have a sense that I should be doing something additional in my
entry and leaving the flash routines. Note the flash routines are located
in
RAM. The rest of the code is in the FLASH. These routines involve
execution
from RAM since the FLASH is not valid during erase or write.

To disable interrupts:
#define DISABLE          ASM(" ori.w #0x0700,%sr")

To enable interrups:
#define ENABLE           ASM(" andi.w #0xf8ff,%sr")

To erase flash:

void FlashErase(int sector)
{
                 FLASH_PTR[0] = 0xF0F0;  // reset device to read mode

                 DISABLE;

                 FLASH_PTR[0x555] = 0xAAAA;      // unlock 1
                 FLASH_PTR[0x2AA] = 0x5555;      // unlock 2
                 FLASH_PTR[0x555] = 0x8080;
                 FLASH_PTR[0x555] = 0xAAAA;
                 FLASH_PTR[0x2AA] = 0x5555;
                 FLASH_PTR[flashSectors[sector].offset/2] = 0x3030;
                 while(FlashStatus(FLASH_PTR)!=STATUS_READY)
                                 TICKLE_WATCHDOG;

                 ENABLE;

}


int FlashStatus(volatile WORD *fp)
{
                  unsigned char d, t;
                  int retry = 1;

again:

                  d = *fp;        /* read data */
                  t = d ^ *fp;    /* read it again and see what toggled */

                  if (t == 0) {           /* no toggles, nothing's
happening */
                                 return STATUS_READY;
                  }
                  else if (t == 0x04) { /* erase-suspend */
                                 if (retry--) goto again;    /* may have
been write completion */
                                 return STATUS_ERSUSP;
                  }
                  else if (t & 0x40) {
                                 if (d & 0x20) {     /* timeout */
                                   return STATUS_TIMEOUT;
                                 }
                                 else {
                                   return STATUS_BUSY;
                                 }
                  }

                  if (retry--) goto again;    /* may have been write
completion */

                  return STATUS_ERROR;
}




---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu <http://www.motorola.com/mcu> 



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ <http://docs.yahoo.com/info/terms/> 






[Non-text portions of this message have been removed]



---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu <http://www.motorola.com/mcu> 



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ <http://docs.yahoo.com/info/terms/> 





---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu <http://www.motorola.com/mcu> 



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ <http://docs.yahoo.com/info/terms/>  






[Non-text portions of this message have been removed]



Yahoo! Groups Sponsor	

ADVERTISEMENT
 <http://rd.yahoo.com/M=251812.3856299.5103760.1261774/D=egroupweb/S=1706554205:HM/A=1754451/R=0/SIG=11tkldm5d/*http://www.netflix.com/Default?mqso=60178323&partid=3856299> click here	
  <http://us.adserver.yahoo.com/l?M=251812.3856299.5103760.1261774/D=egroupmail/S=:HM/A=1754451/rand=114580567> 	

---------------------------------------------------
To unsubscribe from this group, send an email to:
68300-unsubscribe@yahoogroups.com

To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu <http://www.motorola.com/mcu> 



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> . 




[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.