Reply by Anders Lindgren●January 13, 20102010-01-13
distantship101 wrote: >
>
> Hi,
>
> In my application, I use the built-in flash memory of the F249 to log
> some information. For now, I look at the link map to find out where to
> start writing my log (beginning of the first unused flash segment, after
> the end of the CODE segment).
>
> Is there a way to determine this adress automatically ? I'm using IAR
EWB.
Yes, you can use the "#pragma segment" macro in conjunction with the
intrinsics "__segment_begin" and "__segment_end". For example:
Reply by distantship101●January 13, 20102010-01-13
Hi,
Thank you all for your replies. I followed Juan Carlos' suggestion, and it
seems to work. It turns out the alignment can be specified when defining the
segment :
//-P(CODE)CODE00-FFBF
To test this idea, I used the demo msp430x24x_flashwrite_01.c as a base.
I created two arrays in the C-code using this pragma directive placed before
void main()
#pragma dataseg=__data16 jcrSegment
__no_init int jcrFlashC[512];
__no_init int jcrFlashD[512];
#pragma datasegault
I was then able to use them like normal arrays in the C code:
int *Flash_ptrC; // Segment C pointer
int *Flash_ptrD; // Segment D pointer
...
Flash_ptrC = jcrFlashC;
Flash_ptrD = jcrFlashD;
...
*Flash_ptrC++ = value;
...
My test was done only in a simulation-mode - but the arrays updated
correctly and the pointer's addresses matched the segment addresses from
the
map output. No compiler or linker errors.
My map output looked like this
.
*Segments in Address Order*SegmentSpaceStartEndSizeKindAlignDATA16_AN0056 -
00572Relative00120 - 012120128 - 012D6DATA16_I0200Predefined0DATA16_Z0200 -
02012Relative1CSTACK09B0 - 09FF50Relative1DATA16_AN10FE - 10FF2Relative0
CSTART1100 - 111718Relative1ISR_CODE1118Predefined0CODE1118 - 11FDE6Relative
1jcrSegment11FE - 19FD800Relative1RESETFFFE - FFFF2Relative1
.
This seems to keep the *jcrSegmen*t always at the end of the *CODE* segment
and no matter what size data I used (char,int,long,etc) or how big my code
became - it automatically adjusted the jcrSegment start and size.
A few notes:
In all fairness - I didn't beat up this code too hard - I just made
quick
demo just to see if it would work.
You may want to talk with the IAR experts - they may have a better way of
doing this.
Also - I don't know all of the pitfalls with changing the CODE segment
from
a sequential -Z to a random -P placement. It seems that you might lose some
efficiency in the memory placement.
You also may want to experiment with the __data16 in the pragma directive
and use __data20 instead.
Last - I didn't figure out how to elegantly jump to the start of a new
512
segment without alot of pointer math. I have the 512 size - but it's
relative to the end of the CODE segment. Pencils down.
Best Regards,
Juan Carlos
On Tue, Jan 12, 2010 at 12:31 PM, distantship101 wrote:
> Hi,
>
> In my application, I use the built-in flash memory of the F249 to log some
> information. For now, I look at the link map to find out where to start
> writing my log (beginning of the first unused flash segment, after the end
> of the CODE segment).
>
> Is there a way to determine this adress automatically ? I'm using IAR
EWB.
>
> Thanks,
>
> Patrick
>
>
>
Reply by Microbit_Ubuntu●January 12, 20102010-01-12
I think it should be possible to declare a segment for your log, then
read the end of code segment and round it up modulo-512 (ie. set for the
next empty sector) - and then assign the linker segment 'log' to
it.
So, on startup you will have a segment available called log where your C
code can start logging onto.
I haven't used IAR in a long time, but I can't see why you
couldn't put
that in your linker xcl file.
HTH
B rgds
Kris
On Tue, 2010-01-12 at 17:29 +0000, distantship101 wrote: > Hi,
>
> In my application, I use the built-in flash memory of the F249 to log some
information. For now, I look at the link map to find out where to start writing
my log (beginning of the first unused flash segment, after the end of the CODE
segment).
>
> Is there a way to determine this adress automatically ? I'm using IAR
EWB.
>
> Thanks,
>
> Patrick
>
>
Reply by "Redd, Emmett R"●January 12, 20102010-01-12
If it is erased, it will contain only $FF for a large block.
Emmett Redd, Ph.D., Professor mailto:E...@MissouriState.Edu
Physics, Astronomy, and Materials Science Office: 417-836-5221
Missouri State University Dept: 417-838-5131
901 S NATIONAL AVENUE FAX: 417-836-6226
SPRINGFIELD, MO 65897 USA
-----Original Message-----
From: m... [mailto:m...] On Behalf Of distantship101
Sent: Tuesday, January 12, 2010 11:30 AM
To: m...
Subject: [msp430] How to automatically find the start adress of the first unused
flash segment ?
Hi,
In my application, I use the built-in flash memory of the F249 to log some
information. For now, I look at the link map to find out where to start writing
my log (beginning of the first unused flash segment, after the end of the CODE
segment).
Is there a way to determine this adress automatically ? I'm using IAR
EWB.
Thanks,
Patrick
Reply by distantship101●January 12, 20102010-01-12
Hi,
In my application, I use the built-in flash memory of the F249 to log some
information. For now, I look at the link map to find out where to start writing
my log (beginning of the first unused flash segment, after the end of the CODE
segment).
Is there a way to determine this adress automatically ? I'm using IAR
EWB.