Reply by Kamil October 7, 20062006-10-07
--- In m..., Maris Kalbergs
wrote:
>
> Thanks for your program, but it didn't help me out.
> Here is my code and may be you could say that's wrong in it.
>
> MOV #FWKEY+FSSEL1+FN3,&FCTL2 ; SMCLK/2
> MOV #FWKEY,&FCTL3 ; Clear LOCK
> MOV #FWKEY+WRT,&FCTL1 ; Enable write
> MOV.W @R11,&0E010h ; Register to FLASH
> L333 BIT #BUSY,&FCTL3 ; Test BUSY
> JNZ L333
> MOV #FWKEY,&FCTL1 ; Done. Clear WRT
> MOV #FWKEY+LOCK,&FCTL3 ; Set LOCK
>
> R11 - register where is data kept
> &0E010h - address in FLASH where we want to sore our data.

you wrote: 'R11 - register where is data kept'
then @R1 is wrong! you should write mov.w r11, @0e010h not @r11
(i suppose that you have choosen right clock for flash, according to
tech spec of your IC.(a.450kHz))
and of course you have erased this flash block or you have only 1's
in dataword you are writing to.

Beginning Microcontrollers with the MSP430

Reply by Maris Kalbergs October 2, 20062006-10-02
Thanks for your program, but it didn't help me out.
Here is my code and may be you could say that's wrong in it.

MOV #FWKEY+FSSEL1+FN3,&FCTL2 ; SMCLK/2
MOV #FWKEY,&FCTL3 ; Clear LOCK
MOV #FWKEY+WRT,&FCTL1 ; Enable write
MOV.W @R11,&0E010h ; Register to FLASH
L333 BIT #BUSY,&FCTL3 ; Test BUSY
JNZ L333
MOV #FWKEY,&FCTL1 ; Done. Clear WRT
MOV #FWKEY+LOCK,&FCTL3 ; Set LOCK

R11 - register where is data kept
&0E010h - address in FLASH where we want to sore our data.

Thanks

Maris

On Mon, 2006-10-02 at 12:40 +0000, Kamil wrote:
> my patience ran out:)
> here is my code for msp430f149 at 4MHz
> (to better watch code, set fixed font in yahoo groups)
>
> void to_flash_uint(unsigned int *dst, unsigned int *src){
> WDTCTL=WDTPW+WDTHOLD;
> _DINT();
> FCTL2=FWKEY+FSSEL_1+FN3;
> FCTL3=FWKEY;
> FCTL1=FWKEY+WRT;
> *dst=*src; //reference!!!! because of compiler!
> FCTL1=FWKEY;
> FCTL3=FWKEY+LOCK;
> _EINT();// f=MCLK/(8+1)=4MHz/9D4kHz;
> }
>
> sfrb infoB = 0x1000;
> void erase_infoB(void){
> WDTCTL=WDTPW+WDTHOLD;
> _DINT();
> FCTL2=FWKEY+FSSEL_1+FN3;
> FCTL3=FWKEY;
> FCTL1=FWKEY+ERASE;
> infoB = 0; //dummy write
> FCTL1=FWKEY;
> FCTL3=FWKEY+LOCK;
> _EINT();// f=MCLK/(8+1)=4MHz/9D4kHz;
> }
>
> e.g.
>
> unsigned int f_x @ "INFO B" = 0x1234;
> unsigned int x = 0x4321;
> //to RAM:
> x=f_x;
> //to flash
> to_flash_uint(&f_x, &x);
>
> you can't do to_flash_uint(f_x, x);
> you must use reference adressing!
>
> becase (see: 'to_flash_uint' code):
> dst=src;
> would be compiled e.g.
> MOV.W R14, R15 //no flash write!!!!
>
> and
> *dst=*src;
> is compiled into
> MOV.W @R14, 0(R15) //and it is ok!
>
> is it clear enough?
>
Reply by Kamil October 2, 20062006-10-02
my patience ran out:)
here is my code for msp430f149 at 4MHz
(to better watch code, set fixed font in yahoo groups)

void to_flash_uint(unsigned int *dst, unsigned int *src){
WDTCTL=WDTPW+WDTHOLD;
_DINT();
FCTL2=FWKEY+FSSEL_1+FN3;
FCTL3=FWKEY;
FCTL1=FWKEY+WRT;
*dst=*src; //reference!!!! because of compiler!
FCTL1=FWKEY;
FCTL3=FWKEY+LOCK;
_EINT();// f=MCLK/(8+1)=4MHz/9D4kHz;
}

sfrb infoB = 0x1000;
void erase_infoB(void){
WDTCTL=WDTPW+WDTHOLD;
_DINT();
FCTL2=FWKEY+FSSEL_1+FN3;
FCTL3=FWKEY;
FCTL1=FWKEY+ERASE;
infoB = 0; //dummy write
FCTL1=FWKEY;
FCTL3=FWKEY+LOCK;
_EINT();// f=MCLK/(8+1)=4MHz/9D4kHz;
}
e.g.

unsigned int f_x @ "INFO B" = 0x1234;
unsigned int x = 0x4321;
//to RAM:
x=f_x;
//to flash
to_flash_uint(&f_x, &x);

you can't do to_flash_uint(f_x, x);
you must use reference adressing!

becase (see: 'to_flash_uint' code):
dst=src;
would be compiled e.g.
MOV.W R14, R15 //no flash write!!!!

and
*dst=*src;
is compiled into
MOV.W @R14, 0(R15) //and it is ok!
is it clear enough?
Reply by Onestone October 2, 20062006-10-02
SLAUE10B explains address modes and the instruction set in detail. The
technical data sheet for each family member explains the electrical
specifications, for example minimum FLASH write value and flash clock
values, while the Family user guides explain in detail how each part of
the family functions. Appplication examples give code and detailed
explanations for how it operates.

Al

Maris Kalbergs wrote:

> Can you tell me where i can find this very basic things? Because i still
> miss something?
>
> Thanks in advanced
> Maris
>
> On Sun, 2006-10-01 at 23:17 +0930, Onestone wrote:
> > Do not try writing to flash when the supply voltage is below 2.7V.
> > Read
> > the manual for the specs. Then checkout the samples on line there is
> > code that does this in C or asm. If you can't figure out the
> > difference
> > between writing flash using the register indirect mode, and simply
> > writing a register you need to go away and study the very basics
> > before
> > you start trying to write code.
> >
> > Al
> >
> > Maris Kalbergs wrote:
> >
> > > Hello!
> > >
> > > I am newbie in your group and i have one question.
> > > I need to write some registers into flash memory when power supply
> > is
> > > half of max. At the moment i am using MSP430F123.
> > >
> > > Do you have some idea how to write for example R10 register content
> > into
> > > Flash momery?
> > >
> > > Thanks a lot.
> > >
> > > Maris.
> > >
> > >
> > >
> > >----------------------
> > >
> > >
>
>
Reply by Georg Ritter October 2, 20062006-10-02
Maris Kalbergs wrote:
> Can you tell me where i can find this very basic things? Because i still
> miss something?
You are seriously telling, that you cannot figure out where to get basic
information from? You are not trolling, aren't you?

next best library: there you find books on "programming", "electronics",
"microcontrolers".
introductory courses into electronics, sometimes found on the schedules of the
next university or on internet or by manuf or thirdparty training companies
flash memory datasheets from the next best manuf
ask a friend
google
amazon: you can buy books there.
G.
>
> Thanks in advanced
> Maris
>
> On Sun, 2006-10-01 at 23:17 +0930, Onestone wrote:
>
>>Do not try writing to flash when the supply voltage is below 2.7V.
>>Read
>>the manual for the specs. Then checkout the samples on line there is
>>code that does this in C or asm. If you can't figure out the
>>difference
>>between writing flash using the register indirect mode, and simply
>>writing a register you need to go away and study the very basics
>>before
>>you start trying to write code.
>>
>>Al
>>
>>Maris Kalbergs wrote:
>>>Hello!
>>>
>>>I am newbie in your group and i have one question.
>>>I need to write some registers into flash memory when power supply
>>
>>is
>>
>>>half of max. At the moment i am using MSP430F123.
>>>
>>>Do you have some idea how to write for example R10 register content
>>
>>into
>>
>>>Flash momery?
>>>
>>>Thanks a lot.
>>>
>>>Maris.
>>>
>>>
>>>
>>>----------------------
>>>
>>>No virus found in this incoming message.
>>>Checked by AVG Free Edition.
>>>Version: 7.1.405 / Virus Database: 268.12.9/456 - Release Date:
>>
>>25/09/2006
>>
>>
Reply by Maris Kalbergs October 2, 20062006-10-02
Can you tell me where i can find this very basic things? Because i still
miss something?

Thanks in advanced
Maris

On Sun, 2006-10-01 at 23:17 +0930, Onestone wrote:
> Do not try writing to flash when the supply voltage is below 2.7V.
> Read
> the manual for the specs. Then checkout the samples on line there is
> code that does this in C or asm. If you can't figure out the
> difference
> between writing flash using the register indirect mode, and simply
> writing a register you need to go away and study the very basics
> before
> you start trying to write code.
>
> Al
>
> Maris Kalbergs wrote:
>
> > Hello!
> >
> > I am newbie in your group and i have one question.
> > I need to write some registers into flash memory when power supply
> is
> > half of max. At the moment i am using MSP430F123.
> >
> > Do you have some idea how to write for example R10 register content
> into
> > Flash momery?
> >
> > Thanks a lot.
> >
> > Maris.
> >
> >
> >
> >----------------------
> >
> >No virus found in this incoming message.
> >Checked by AVG Free Edition.
> >Version: 7.1.405 / Virus Database: 268.12.9/456 - Release Date:
> 25/09/2006
> >
> >
>
Reply by Onestone October 1, 20062006-10-01
Do not try writing to flash when the supply voltage is below 2.7V. Read
the manual for the specs. Then checkout the samples on line there is
code that does this in C or asm. If you can't figure out the difference
between writing flash using the register indirect mode, and simply
writing a register you need to go away and study the very basics before
you start trying to write code.

Al

Maris Kalbergs wrote:

> Hello!
>
> I am newbie in your group and i have one question.
> I need to write some registers into flash memory when power supply is
> half of max. At the moment i am using MSP430F123.
>
> Do you have some idea how to write for example R10 register content into
> Flash momery?
>
> Thanks a lot.
>
> Maris.
>
>
>
>
>
>
Reply by old_cow_yellow September 29, 20062006-09-29
(1) If your code is in assembly, accessing registers
is just as easy as, actually easier then, accessing
SRAM. If your code is C, why do you care what are in
registers? The C-compiler decides what the registers
are used for at any given moment. If you do not know
know what C-compiler is doing, and do not know how
to access registers, writing them in Flash will not
help you.

(2) You said you want to do this when the power is
going down. I think that is the worst time to start
altering Flash. You need higher then normal voltage
to erase/write Flash. And it takes a lot of current
and time to do so. If the power is already marginal,
start altering Flash will most likely not
succeed.

How about use "printf" to write everything on paper,
use a scanner to capture the image, use OCR to
convert them back to ASCII, and use "scanf" to restore
everything ;-)

--- In m..., Maris Kalbergs
wrote:
>
> Ok i read it all but still i have problem. In examples they are
storing
> into flash only constants, but how to make to store content of some
> register?
>
> Maris
>
> On Fri, 2006-09-29 at 12:34 +0000, Kamil wrote:
> > p.s. i've got SLAU049F 2006y
> >
Reply by Maris Kalbergs September 29, 20062006-09-29
Ok i read it all but still i have problem. In examples they are storing
into flash only constants, but how to make to store content of some
register?

Maris

On Fri, 2006-09-29 at 12:34 +0000, Kamil wrote:
> p.s. i've got SLAU049F 2006y
>
Reply by Kamil September 29, 20062006-09-29
p.s. i've got SLAU049F 2006y