From 4fac3037e0e38511a3c9e72893a842cde6039f71 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Mon, 15 Nov 2010 21:52:54 +0000 Subject: [PATCH] Fixed a bug found by Moritz Straube - writing to the internal flash would lock up contikimac. The problem was due to the IFG1 being reset to zero before writing to flash. --- cpu/msp430/flash.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cpu/msp430/flash.c b/cpu/msp430/flash.c index df7d527da..50ff315a2 100644 --- a/cpu/msp430/flash.c +++ b/cpu/msp430/flash.c @@ -29,7 +29,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * - * $Id: flash.c,v 1.2 2007/11/17 10:28:04 adamdunkels Exp $ + * $Id: flash.c,v 1.3 2010/11/15 21:52:54 adamdunkels Exp $ * * Author: Adam Dunkels * @@ -51,27 +51,28 @@ static unsigned short ie1, ie2; void flash_setup(void) { - - /* Disable all interrupts. */ + /* disable all interrupts to protect CPU + during programming from system crash */ + _DINT(); /* Clear interrupt flag1. */ - IFG1 = 0; + /* IFG1 = 0; */ + /* The IFG1 = 0; statement locks up contikimac - not sure if this + statement needs to be here at all. I've removed it for now, since + it seems to work, but leave this little note here in case someone + stumbles over this code at some point. */ /* Stop watchdog. */ watchdog_stop(); /* DCO(SMCLK) is 2,4576MHz, /6 = 409600 Hz select SMCLK for flash timing, divider 5+1 */ - FCTL2 = 0xA5C5; - - /* disable all interrupts to protect CPU - during programming from system crash */ - _DINT(); + FCTL2 = 0xA5C5; /* disable all NMI-Interrupt sources */ ie1 = IE1; ie2 = IE2; - IE1 = 0x00; + IE1 = 0x00; IE2 = 0x00; } /*---------------------------------------------------------------------------*/