Problem erasing info-mem sector

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem erasing info-mem sector

nimish hirekodi
Hi!
   We are trying to write to info-mem. But our program
hangs while erasing sector. Can anyone help?
Best Regards,
Rajat.



Source code:

#include<msp430x14x.h>
#include<math.h>
#include<signal.h>

unsigned char *ucptrSeg1_Address;
unsigned char *ucptrSeg2_Address;
unsigned char ucFIndex;

void vfnWriteData2Flash(unsigned char
*ucptrFlashAddress,
                                                unsigned char *ucptrData,
                                                unsigned char ucNoOfBytes);

volatile unsigned int __attribute__ ((section
(".infomem")))
Iarray[20];
volatile unsigned char __attribute__ ((section
(".infomem")))
Carray[20];

int main(void)
{
        int num=1;

        vfnWriteData2Flash((unsigned char*)Iarray,(unsigned
char *)&num, (char)sizeof(num));
       
        while(1);

        return(0);
}


void vfnWriteData2Flash(unsigned char
*ucptrFlashAddress,
                                                unsigned char *ucptrData,
                                                unsigned char ucNoOfBytes)
{
         
          dint();  
     
      FCTL2 = FWKEY + FSSEL_1 + FN2 + FN4;  // MCLK IS
SELECTED  
      if(FCTL3 & LOCK)                
        FCTL3 = FWKEY + (FCTL3 & 0x00ef);   // make
Lock = 0,if it is set
      while(FCTL3 & BUSY);          // wait till BUSY
= 0
   
      // erase SegB
      FCTL1 = FWKEY + ERASE;          // SET Erase bit
      *(unsigned char*)0x1000 = 0x00;
      while(FCTL3 & BUSY);          // wait till BUSY
= 0
       
      // Move all the data in Data segA to Backup segB
      FCTL1 = FWKEY + WRT;          // SET BLKWRT bit
   
      ucptrSeg1_Address = (unsigned char *)0x1080;    

      ucptrSeg2_Address = (unsigned char *)0x1000;
   
      for(ucFIndex=0;ucFIndex < 128;ucFIndex++)      

        *(ucptrSeg2_Address++) =
*(ucptrSeg1_Address++);    

      FCTL1 = FWKEY;    
      while(FCTL3 & BUSY);          // wait till Write
operation is going on

      // erase SegA
      FCTL1 = FWKEY + ERASE;          // SET Erase bit
      *(unsigned char*)0x1080 = 0x00;
      while(FCTL3 & BUSY);          // wait till BUSY
= 0
   
      // move back all the data from SegB from SegA
and change the data
      FCTL1 = FWKEY + WRT;          // SET BLKWRT bit
   
      ucptrSeg1_Address = (unsigned char *)0x1080;    

      ucptrSeg2_Address = (unsigned char *)0x1000;
   
      for(ucFIndex=0;ucFIndex < 128;ucFIndex++)
      {
       if(ucptrSeg1_Address == ucptrFlashAddress)
        {
          ucNoOfBytes += ucFIndex;
          while(ucFIndex < ucNoOfBytes)
         {
          *(ucptrSeg1_Address++) = *(ucptrData++);
          ucFIndex++;
          ucptrSeg2_Address++;
         }
         ucFIndex--;
        }
       else
         *(ucptrSeg1_Address++) =
*(ucptrSeg2_Address++);  
      }

      FCTL1 = FWKEY;    
      while(FCTL3 & BUSY);          // wait till Write
operation is going on
      FCTL3 = FWKEY + LOCK;         // make Lock = 1,
avoiding erase or write

      eint();  
}


               
__________________________________________________________
How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem erasing info-mem sector

N. Coesel
At 14:55 18-07-05 +0100, you wrote:
>Hi!
>   We are trying to write to info-mem. But our program
>hangs while erasing sector. Can anyone help?
>Best Regards,
>Rajat.

You should follow the MSP430 manual chapters on erasing and writing the
internal flash. If you are running your software from the internal flash,
waiting for the busy bit is problaby the thing you are doing wrong.

Here a bit of my code:

                //erase sector
                dint();
                FCTL3=0xA500;
                FCTL1=0xA500 | 2;
                *((unsigned char *)address)=0; //dumy write, now the erase starts.
                FCTL3=0xA500 | 0x10;
                eint();

Writing is just as simple. The processor halts automatically during write
and erase.

Nico Coesel



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem erasing info-mem sector

Rolf Freitag
In reply to this post by nimish hirekodi

Hi,

in the examples from the CVS server you can find several examples e. g. by searching
for "FWKEY".

Regards,

Rolf

[hidden email] schrieb am 18.07.05 15:58:13:

>
> Hi!
>    We are trying to write to info-mem. But our program
> hangs while erasing sector. Can anyone help?
> Best Regards,
> Rajat.
>
>
>
> Source code:
>
> #include<msp430x14x.h>
> #include<math.h>
> #include<signal.h>
>
> unsigned char *ucptrSeg1_Address;
> unsigned char *ucptrSeg2_Address;
> unsigned char ucFIndex;
>
> void vfnWriteData2Flash(unsigned char
> *ucptrFlashAddress,
> unsigned char *ucptrData,
> unsigned char ucNoOfBytes);
>
> volatile unsigned int __attribute__ ((section
> (".infomem")))
> Iarray[20];
> volatile unsigned char __attribute__ ((section
> (".infomem")))
> Carray[20];
>
> int main(void)
> {
> int num=1;
>
> vfnWriteData2Flash((unsigned char*)Iarray,(unsigned
> char *)&num, (char)sizeof(num));
>
> while(1);
>
> return(0);
> }
>
>
> void vfnWriteData2Flash(unsigned char
> *ucptrFlashAddress,
> unsigned char *ucptrData,
> unsigned char ucNoOfBytes)
> {
>  
>  dint();  
>      
>       FCTL2 = FWKEY + FSSEL_1 + FN2 + FN4;  // MCLK IS
> SELECTED  
>       if(FCTL3 & LOCK)                
>         FCTL3 = FWKEY + (FCTL3 & 0x00ef);   // make
> Lock = 0,if it is set
>       while(FCTL3 & BUSY);          // wait till BUSY
> = 0
>    
>       // erase SegB
>       FCTL1 = FWKEY + ERASE;          // SET Erase bit
>       *(unsigned char*)0x1000 = 0x00;
>       while(FCTL3 & BUSY);          // wait till BUSY
> = 0
>        
>       // Move all the data in Data segA to Backup segB
>       FCTL1 = FWKEY + WRT;          // SET BLKWRT bit
>    
>       ucptrSeg1_Address = (unsigned char *)0x1080;    
>
>       ucptrSeg2_Address = (unsigned char *)0x1000;
>    
>       for(ucFIndex=0;ucFIndex < 128;ucFIndex++)      
>
>         *(ucptrSeg2_Address++) =
> *(ucptrSeg1_Address++);    
>
>       FCTL1 = FWKEY;    
>       while(FCTL3 & BUSY);          // wait till Write
> operation is going on
>
>       // erase SegA
>       FCTL1 = FWKEY + ERASE;          // SET Erase bit
>       *(unsigned char*)0x1080 = 0x00;
>       while(FCTL3 & BUSY);          // wait till BUSY
> = 0
>    
>       // move back all the data from SegB from SegA
> and change the data
>       FCTL1 = FWKEY + WRT;          // SET BLKWRT bit
>    
>       ucptrSeg1_Address = (unsigned char *)0x1080;    
>
>       ucptrSeg2_Address = (unsigned char *)0x1000;
>    
>       for(ucFIndex=0;ucFIndex < 128;ucFIndex++)
>       {
>        if(ucptrSeg1_Address == ucptrFlashAddress)
>         {
>           ucNoOfBytes += ucFIndex;
>           while(ucFIndex < ucNoOfBytes)
>          {
>           *(ucptrSeg1_Address++) = *(ucptrData++);
>           ucFIndex++;
>           ucptrSeg2_Address++;
>          }
>          ucFIndex--;
>         }
>        else
>          *(ucptrSeg1_Address++) =
> *(ucptrSeg2_Address++);  
>       }
>
>       FCTL1 = FWKEY;    
>       while(FCTL3 & BUSY);          // wait till Write
> operation is going on
>       FCTL3 = FWKEY + LOCK;         // make Lock = 1,
> avoiding erase or write
>
>       eint();  
> }
>
>
>
> __________________________________________________________
> How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Mspgcc-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem erasing info-mem sector

Jonas Sølvhøj
Hi,

I'm trying to compile the jtag library from cvs. I get the following
error:

cd hardware_access; make all
make[1]: Entering directory `work/jtag/hardware_access'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `work/jtag/hardware_access'
cd funclets; make all
make[1]: Entering directory `work/jtag/funclets'
msp430-gcc -mmcu=msp430x1121 -D_GNU_ASSEMBLER_   -c -o regtest.o
regtest.S
msp430-ld -T msp430xRAM.x -o regtest.elf regtest.o
msp430-ld:msp430xRAM.x:115: warning: memory region infomem not declared
msp430-ld:msp430xRAM.x:131: warning: memory region vectors not declared
msp430-ld: regtest.elf: could not find output section .vectors for input
section .vectors
msp430-ld: final link failed: Nonrepresentable section on output
make[1]: *** [regtest.elf] Error 1
rm regtest.o
make[1]: Leaving directory `work/jtag/funclets'
make: *** [funclets] Error 2

I have compiled the library before without errors. What am I doing wrong
this time?

Jonas



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users