Hi,

I found in "signal.h" this line:
#define _RESET()        void  __attribute__ ((naked))  _reset_vector__(void)

-Is it the default function which manage reset interrupt?
-Can anyone explain me what this function does precisely since I must write my 
own?
-Can I bypass it by writing a fct like:
  interrupt(RESET_VECTOR) my_reset_handler(void){
    // my own code
  }
-When the reset handler is call? Is it only AFTER a PUC?

Thanks a lot!
I think I found a very good way to reprogram flash (very secure field upgrade 
software). I will post it as soon as it will be done!
Fred

-------------------------------

Frederic Beaulieu, M.Sc.

Research and Development

NewTrax Technologies Inc.

http://www.newtraxtech.com/


-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of 
[email protected]
Sent: Thursday, March 24, 2005 2:46 AM
To: [email protected]
Subject: [Mspgcc-users] RE: Flash reprogramming via RS232

> At 15:31 23-03-05 -0500, you wrote:
> >        Hi all,     I want to reprogram my F1612 in the field via 
RS232. To
> >be able to use block writing, I must run my reprogramming code from RAM 
and
> >I wonder how I can transfer a function (already in flash) there. I must
> >know the code start and stop address to copy the entire code in RAM and
> >then change the PC register to start reprogramming. I would like to do 
this
> >in C if it’s possible.     Thanks,  Fred 
> 

Hi Fred,

if you do not care about a few wasted ram bytes during the reprogramming 
you can do the following:
Write your reprogramming code as usual, compile and check the size of the 
reprogramming function in the map file. Now use a character array with the 
size of your function plus a little bit of headroom. You can memcpy your 
function to the character array and call it in ram. Here the solution i 
use (in my example the character array is global because i use a dedicated 
boot programm for reprogramming and i do not care about the wasted ram. 
But of course the character array can also live in the stack so the ram 
space is only wasted during reprogramming):

#define byte   unsigned char
#define sbyte  signed char
#define word   unsigned short int
#define sword  signed short int
#define dword  unsigned long int
#define sdword signed long int
#define bool   unsigned char

typedef void(*vwwpwFnctPtr)(word, word *, word );
static char fnct_data[128];
void DoWriteSegment (word Dest, word *Src, word BlckCnt );


/********************************************************/
sword WriteSegment ( word Dest, word *Src, word len ) {
   word blockcnt;
   vwwpwFnctPtr copyfnct = (vwwpwFnctPtr)fnct_data;

   if ( (Dest < 0x1100) OR ((Dest + len) > 0xE000) ) { 
      return -1;
   }

   blockcnt = len / 64;     // ein Block = 64 Byte
   if ( (len % 64) != 0 ) blockcnt++;

   // Watch Busy Bit
   while ( (FCTL3 & BUSY) != 0 );

   FCTL2 = FWKEY | FSSEL_1 | 19; 

   memcpy(fnct_data,DoWriteSegment,sizeof(fnct_data)); 
   copyfnct(Dest,Src,blockcnt); 

   return 0;
}

/********************************************************/
void DoWriteSegment (word Dest, word *Src, word BlckCnt ) {
   word m;

   dint();
   // Reset LockBit
   FCTL3 = FWKEY;

   while ( BlckCnt > 0 ) {
      BlckCnt--;
      // Set Write and WriteBlock Bit
      FCTL1 = FWKEY | WRT | BLKWRT;

      // Execute Write to segment
      for ( m = 64/2; m > 0 ; m-- ) {
         *((word*)Dest) = *Src++;
         Dest += 2;
         while ( (FCTL3 & WAIT) == 0 );
      }

      // Clear Write bits
      FCTL1 = FWKEY;

      // Watch Busy Bit
      while ( (FCTL3 & BUSY) != 0 );
   }

   // Set Lock Bit
   FCTL3 = FWKEY + LOCK;
   eint();
}

Cheers,
Christian
NHYXuʲ2myм*M۝
-ӓ݊uyiؕ՝ڰIyvڰʊWƦXj؞Ǟ׵˭ojHi۱٢ovj

-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.0 - Release Date: 3/21/2005
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 3/23/2005
 


Reply via email to