Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » MSPGCC
  • » [Mspgcc-users] MSP430X with MSPGCC and MSP430F543XA [RSS Feed]

#1 Dec. 8, 2010 12:53:59

P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] MSP430X with MSPGCC and MSP430F543XA


Hi all,

I would like to share my experience (quite successful ;O) with MSP430X
and MSPGCC with Cygwin 1.7.7.
Please notice that I'm quite a new to MSPGCC and MSP430X, but this post
may help other beginners.
Along this post , you'll find some remaining questions, if you have any
informations about theses or others, do not hesitate to share them.

To get the compiler working on my cygwin with MSP430X extension, I've
simply followed the the simple tutorial:http://sourceforge.net/apps/mediawiki/mspgcc/index.php?title=Building_MSPGCC_from_Source_CodeDownloading steps were very ok, but here are some remarks about
compilation steps.

1) *** COMPILING BINUTILS ***
cd binutils-2.19
patch -p1< ../packaging/patches/binutils-2.19-patch
./configure --target=msp430 --prefix=/opt/msp430-X
make

ISSUE1: During compilation I got a "segmentation fault" with gcc on
arparse.c compilation
==> I just removed (set to empty) the NO_WERROR variable inside the
binutils/makefile.

make install


2) *** COMPILING GCC MSP430X ***
cp -av gcc/gcc-3.3/* gcc-3.2.3
cd gcc-3.2.3
./configure --target=msp430 --prefix=/opt/msp430-z1
make

ISSUE2: Some of the source files (gcc-3.2.3/config.sub,
gcc-3.2.3/config.gcc) were containing '\r' (0x15) char.
==> I just get ride of them with commands like:
mv config.sub config.sub.old
tr -d '\15'< config.sub.old> config.sub
BUT notice that i found later that this issuecould have been solved
inserting
"set SHELLOPTS=igncr" inside "cygwin.bat" just after first line "@echo off"

make install

ISSUE3: When trying to make Install i got
"*** No rule to make target `../libiberty/libiberty.a', needed by
`gengenrtl..."
==> I had to recompile manually libiberty:
cd libiberty
make
..
cd ..

make install



3) *** COMPILING libc ***
cd msp430-libc/src
Think about modifying the Makefile:
PREFIX = /opt/msp430.X
And copy or link your freshly compiled "msp430-gcc.exe" to
msp430/bin/gcc.exe
then:
make
make install
ISSUE4: On my side make install failed so I just did
make install-multilib

IMPORTANT NOTE: hardware multiplication is not well supported, hence
think about compiling AND linking your futur source code with the
option: "--mdisable-hwmul"

<Q1> IS THERE ANY WORKS ON IMPROVEMENTS FOR MSP430X.( i.e. support of
hardware multiplications, functions pointers etc ...) ? IS THE MSP430X
BRANCH STILL ALIVE ?


ISSUE5: To get a project correctly linked i had to comment all the
source code inside "vuprintf()" function of "vuprintf.c", and recompile
and re-install the libc ?

<Q2> I'VE READ THAT THERE IS A PROBLEM WITH FUNCTION POINTERS ?
There's a first comment about this here:http://comments.gmane.org/gmane.comp.hardware.texas-instruments.msp430.gcc.user/8993Thanks, but does any one now about a (future) correction in MSP430X ?


ISSUE6: Even if compiled with "--mdisable-hwmul" option a source
containing a logical shift left on long can't be linked :
{
long hi;
...
hi<<= 1;
...
}
<Q3> PLEASE HELP FOR THIS ISSUE6 ?


ISSUE7: As I have to use an F543xA mcu I had to import all the I/Os
definition from msp430gcc 4.4.4 ! (merging MSP430X branch with mspgcc4
would be nice !)
mv /opt/msp430.X/msp430/include /opt/msp430.X/msp430/include.old
cp -r /opt/msp430-gcc-4.4.4/msp430/include /opt/msp430.X/msp430/include

<Q4> DO YOU SEE ANY RISK ABOUT THE SOLUTION TO THIS LAST ISSUE 7 ?


ISSUE8: To get some flash access working
Add #include "flash.h" inside include/msp430x54xx.h (coming from 4.4.4)

Then, I could compile and upload small and "quite big" programs that use
extended flash using
__attribute__((__far__))
And functions that are in far memory seem to work correctly.

NOTE: I use "mspdebug 0.12" and the MSP43F543XA BSL with a flying camp
dongle to upload software, That's nice. The only issue is the BSL
activation sequence which, for MSP430F543XA, must be inverted on the
TEST signal compared to the TI SLAU319a documentation.

I have to do more tests now.
But if any of you have any comments or other experience with MSP430.X
please feedback.

Regards

--
Pierre-emmanuel




Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

#2 Dec. 8, 2010 13:50:01

Peter B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] MSP430X with MSPGCC and MSP430F543XA


I personally don't use or maintain the MSP430X branch, though it is my
intention to merge it into mspgcc4 after completing the uniarch
modifications. Some of the problems you note have either already been fixed
in mspgcc4, or will be addressed when 20-bit support is integrated.

Offhand, I think it should be safe to copy the legacy (or even TI) headers
from the more recent msp430-libc releases and use them with the MSP430X
branch. You should not use the rest of the newer msp430-libc, though,
because it specifically does not work correctly with 20-bit pointers (a
recent bug fix required disabling that support until it could be more
carefully reviewed).

I have strong hopes of spending the last half of December on this, and
finally getting a major update out for people to try. Reality keeps
intruding on my plans, though.

Peter

On Wed, Dec 8, 2010 at 6:51 AM, Pierre-emmanuel <pe.gou***@*atteco.fr>wrote:

> Hi all,
>
> I would like to share my experience (quite successful ;O) with MSP430X
> and MSPGCC with Cygwin 1.7.7.
> Please notice that I'm quite a new to MSPGCC and MSP430X, but this post
> may help other beginners.
> Along this post , you'll find some remaining questions, if you have any
> informations about theses or others, do not hesitate to share them.
>
> To get the compiler working on my cygwin with MSP430X extension, I've
> simply followed the the simple tutorial:
>
>http://sourceforge.net/apps/mediawiki/mspgcc/index.php?title=Building_MSPGCC_from_Source_Code> Downloading steps were very ok, but here are some remarks about
> compilation steps.
>
> 1) *** COMPILING BINUTILS ***
> cd binutils-2.19
> patch -p1< ../packaging/patches/binutils-2.19-patch
> ./configure --target=msp430 --prefix=/opt/msp430-X
> make
>
> ISSUE1: During compilation I got a "segmentation fault" with gcc on
> arparse.c compilation
> ==> I just removed (set to empty) the NO_WERROR variable inside the
> binutils/makefile.
>
> make install
>
>
> 2) *** COMPILING GCC MSP430X ***
> cp -av gcc/gcc-3.3/* gcc-3.2.3
> cd gcc-3.2.3
> ./configure --target=msp430 --prefix=/opt/msp430-z1
> make
>
> ISSUE2: Some of the source files (gcc-3.2.3/config.sub,
> gcc-3.2.3/config.gcc) were containing '\r' (0x15) char.
> ==> I just get ride of them with commands like:
> mv config.sub config.sub.old
> tr -d '\15'< config.sub.old> config.sub
> BUT notice that i found later that this issuecould have been solved
> inserting
> "set SHELLOPTS=igncr" inside "cygwin.bat" just after first line "@echo off"
>
> make install
>
> ISSUE3: When trying to make Install i got
> "*** No rule to make target `../libiberty/libiberty.a', needed by
> `gengenrtl..."
> ==> I had to recompile manually libiberty:
> cd libiberty
> make
> ..
> cd ..
>
> make install
>
>
>
> 3) *** COMPILING libc ***
> cd msp430-libc/src
> Think about modifying the Makefile:
> PREFIX = /opt/msp430.X
> And copy or link your freshly compiled "msp430-gcc.exe" to
> msp430/bin/gcc.exe
> then:
> make
> make install
> ISSUE4: On my side make install failed so I just did
> make install-multilib
>
> IMPORTANT NOTE: hardware multiplication is not well supported, hence
> think about compiling AND linking your futur source code with the
> option: "--mdisable-hwmul"
>
> <Q1> IS THERE ANY WORKS ON IMPROVEMENTS FOR MSP430X.( i.e. support of
> hardware multiplications, functions pointers etc ...) ? IS THE MSP430X
> BRANCH STILL ALIVE ?
>
>
> ISSUE5: To get a project correctly linked i had to comment all the
> source code inside "vuprintf()" function of "vuprintf.c", and recompile
> and re-install the libc ?
>
> <Q2> I'VE READ THAT THERE IS A PROBLEM WITH FUNCTION POINTERS ?
> There's a first comment about this here:
>
>http://comments.gmane.org/gmane.comp.hardware.texas-instruments.msp430.gcc.user/8993> Thanks, but does any one now about a (future) correction in MSP430X ?
>
>
> ISSUE6: Even if compiled with "--mdisable-hwmul" option a source
> containing a logical shift left on long can't be linked :
> {
> long hi;
> ...
> hi<<= 1;
> ...
> }
> <Q3> PLEASE HELP FOR THIS ISSUE6 ?
>
>
> ISSUE7: As I have to use an F543xA mcu I had to import all the I/Os
> definition from msp430gcc 4.4.4 ! (merging MSP430X branch with mspgcc4
> would be nice !)
> mv /opt/msp430.X/msp430/include /opt/msp430.X/msp430/include.old
> cp -r /opt/msp430-gcc-4.4.4/msp430/include /opt/msp430.X/msp430/include
>
> <Q4> DO YOU SEE ANY RISK ABOUT THE SOLUTION TO THIS LAST ISSUE 7 ?
>
>
> ISSUE8: To get some flash access working
> Add #include "flash.h" inside include/msp430x54xx.h (coming from 4.4.4)
>
> Then, I could compile and upload small and "quite big" programs that use
> extended flash using
> __attribute__((__far__))
> And functions that are in far memory seem to work correctly.
>
> NOTE: I use "mspdebug 0.12" and the MSP43F543XA BSL with a flying camp
> dongle to upload software, That's nice. The only issue is the BSL
> activation sequence which, for MSP430F543XA, must be inverted on the
> TEST signal compared to the TI SLAU319a documentation.
>
> I have to do more tests now.
> But if any of you have any comments or other experience with MSP430.X
> please feedback.
>
> Regards
>
> --
> Pierre-emmanuel
>
>
>
>
>
> Mspgcc-users mailing list
> Mspgcc-us***@*ists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/mspgcc-users>
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

#3 Dec. 8, 2010 13:54:40

t.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] MSP430X with MSPGCC and MSP430F543XA


Le 08/12/2010 13:51, Pierre-emmanuel a écrit :
> Hi all,
>
> I would like to share my experience (quite successful ;O) with MSP430X
> and MSPGCC with Cygwin 1.7.7.
> Please notice that I'm quite a new to MSPGCC and MSP430X, but this post
> may help other beginners.
> Along this post , you'll find some remaining questions, if you have any
> informations about theses or others, do not hesitate to share them.
>
> To get the compiler working on my cygwin with MSP430X extension, I've
> simply followed the the simple tutorial:
>http://sourceforge.net/apps/mediawiki/mspgcc/index.php?title=Building_MSPGCC_from_Source_Code> Downloading steps were very ok, but here are some remarks about
> compilation steps.
>
> 1) *** COMPILING BINUTILS ***
> cd binutils-2.19
> patch -p1< ../packaging/patches/binutils-2.19-patch
> ../configure --target=msp430 --prefix=/opt/msp430-X
> make
>
> ISSUE1: During compilation I got a "segmentation fault" with gcc on
> arparse.c compilation
> ==> I just removed (set to empty) the NO_WERROR variable inside the
> binutils/makefile.
>
> make install
>
>
> 2) *** COMPILING GCC MSP430X ***
> cp -av gcc/gcc-3.3/* gcc-3.2.3
> cd gcc-3.2.3
> ../configure --target=msp430 --prefix=/opt/msp430-z1
> make
>
> ISSUE2: Some of the source files (gcc-3.2.3/config.sub,
> gcc-3.2.3/config.gcc) were containing '\r' (0x15) char.
> ==> I just get ride of them with commands like:
> mv config.sub config.sub.old
> tr -d '\15'< config.sub.old> config.sub
> BUT notice that i found later that this issuecould have been solved
> inserting
> "set SHELLOPTS=igncr" inside "cygwin.bat" just after first line "@echo off"
>
> make install
>
> ISSUE3: When trying to make Install i got
> "*** No rule to make target `../libiberty/libiberty.a', needed by
> `gengenrtl..."
> ==> I had to recompile manually libiberty:
> cd libiberty
> make
> ...
> cd ..
>
> make install
>
>
>
> 3) *** COMPILING libc ***
> cd msp430-libc/src
> Think about modifying the Makefile:
> PREFIX = /opt/msp430.X
> And copy or link your freshly compiled "msp430-gcc.exe" to
> msp430/bin/gcc.exe
> then:
> make
> make install
> ISSUE4: On my side make install failed so I just did
> make install-multilib
>
> IMPORTANT NOTE: hardware multiplication is not well supported, hence
> think about compiling AND linking your futur source code with the
> option: "--mdisable-hwmul"
>
> <Q1> IS THERE ANY WORKS ON IMPROVEMENTS FOR MSP430X.( i.e. support of
> hardware multiplications, functions pointers etc ...) ? IS THE MSP430X
> BRANCH STILL ALIVE ?
>
>
> ISSUE5: To get a project correctly linked i had to comment all the
> source code inside "vuprintf()" function of "vuprintf.c", and recompile
> and re-install the libc ?
>
> <Q2> I'VE READ THAT THERE IS A PROBLEM WITH FUNCTION POINTERS ?
> There's a first comment about this here:
>http://comments.gmane.org/gmane.comp.hardware.texas-instruments.msp430.gcc.user/8993> Thanks, but does any one now about a (future) correction in MSP430X ?
>
>
> ISSUE6: Even if compiled with "--mdisable-hwmul" option a source
> containing a logical shift left on long can't be linked :
> {
> long hi;
> ...
> hi<<= 1;
> ...
> }
> <Q3> PLEASE HELP FOR THIS ISSUE6 ?
>
>
> ISSUE7: As I have to use an F543xA mcu I had to import all the I/Os
> definition from msp430gcc 4.4.4 ! (merging MSP430X branch with mspgcc4
> would be nice !)
> mv /opt/msp430.X/msp430/include /opt/msp430.X/msp430/include.old
> cp -r /opt/msp430-gcc-4.4.4/msp430/include /opt/msp430.X/msp430/include
>
> <Q4> DO YOU SEE ANY RISK ABOUT THE SOLUTION TO THIS LAST ISSUE 7 ?
>
>
> ISSUE8: To get some flash access working
> Add #include "flash.h" inside include/msp430x54xx.h (coming from 4.4.4)
>
> Then, I could compile and upload small and "quite big" programs that use
> extended flash using
> __attribute__((__far__))
> And functions that are in far memory seem to work correctly.
>
> NOTE: I use "mspdebug 0.12" and the MSP43F543XA BSL with a flying camp
> dongle to upload software, That's nice. The only issue is the BSL
> activation sequence which, for MSP430F543XA, must be inverted on the
> TEST signal compared to the TI SLAU319a documentation.
>
> I have to do more tests now.
> But if any of you have any comments or other experience with MSP430.X
> please feedback.
>
> Regards
>
Hi,

Thanks "Pierre-emmanuel" for your post!

I use the MSP430X branch (MSPGCC3.2.3) sine a few months with MSP430F5418.

Some bugs are not solved at this time, but with some tips you can use
all the MCU memory space !

BUGS: far datas pointers, and far functions pointers are not supported !

So, I locate all my datas in the lower memory space ( below 64K ). Also,
I put too alls functions called by pointers.
Then the rest of code is located in the upper memory space with the
«FAR» attribute.

To do this, I use definitions in my common C-header (common.h).
I define this:
...

#if ( defined(__MSP430X2__) || defined(__MSP430X__) )
#ifndef __MSP430X_ADDR_16BIT__
#define far __attribute__((__far__))
#define __MSP430X_ADDR_20BIT__
#warning "use ADDR_20BIT"
#endif
#else
#endif

#if defined(__MSP430X_ADDR_20BIT__)
#define CODE far
#else
#define CODE
#endif

/* For assembly language */
#if defined(__MSP430X_ADDR_20BIT__)
#define _PUSH_ pushx.a
#define _POP_ popx.a
#define _RET_ reta
#define _CALL_ calla
#define _BR_ bra
#define _CODE_ASM_ .section ".fartext"
#else
#define _PUSH_ push.w
#define _POP_ pop.w
#define _RET_ ret
#define _CALL_ call
#define _BR_ br
#define _CODE_ASM_ .text
#endif

How to use it :

1) In C language

On my program, I declare my function like this:

CODE
void my_fucntion(void)
{
...
}

If I change addressing (16bis/20bis) with compiler option, functions are
located on the right place automaticaly !

Howerver be careful, with functions pointers! because the compiler store
only 16bits of the address, and the call is made with indirect access (
calla @R15) !
The function called is terminated by a «RETA». So the stack will be
corrrupt after the return !

Workaround : Don't use the standard writting !

I show you my example with an array of functions pointer :
#include "common.h"

...

#if defined(__MSP430X_ADDR_20BIT__)
void *Ptr = Hart_Ressource_Tab._Hart_fnct_Read;
r = call_Hart_Ressource(ix_tx_data, ix_rx_data, 0, Ptr);
#else
# standard writting ...
r = Hart_Ressource_Tab._Hart_fnct_Read(ix_tx_data, ix_rx_data, 0);
#endif

I use the « call_Hart_Ressource » function, like this
R15 = ix_tx_data
R14 = ix_rx_data
R13 = len
R12 = Ptr_fnct

...
#if defined(__MSP430X_ADDR_20BIT__)
unsigned char call_Hart_Ressource(unsigned char ix_tx_data, unsigned
char ix_rx_data, unsigned char len, void *Ptr_fnct)
{
#warning "Bug 20bits workaround! Function should be placed in lower
memory space !"
asm volatile(" calla R12");
}
#endif
...

2) In assembly language

Instead of writting standard instructions, replace it by the definitions
in common.h !

For section define:
.text/.section ".fartext" -> _CODE_ASM_

For some typicals instructions :
ret/reta -> _RET_
call/calla -> _CALL_
br/bra -> _BR_
push/pushx.a -> _PUSH_
pop/popx.a -> _POP_

Example on my sleep function :

#include "common.h"

.global Sleep

_CODE_ASM_
Sleep:
bic.b #HWD,&P_HWD_OUT; // port = 0
bis #CPUOFF,SR
nop ; zzz
bis.b #HWD,&P_HWD_OUT; // port = 1
_RET_


If someone find an other way to solve these problems or if you have more
tips, please post it !

Sorry for my poor English ;)

Regards, Thierry









Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

#4 Dec. 9, 2010 10:00:03

t.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] MSP430X with MSPGCC and MSP430F543XA


Hi again,

Following my last post, I noticed that libraries (libc) are located
below the "64K" limit, in ".text" section!
My first question is; How to put them inside the ".fartext" section to
save memory space for datas ?

I use Objdump to see what the compiler does ! In the ".text" section I
have all mixed informations : source and disassemby language, but on
".fartext" section I have only disassembly language !

I try some syntax without success !

$(OBJDUMP) -h -d -S $(DIR_OBJ)$@ > lst/$...@.lst

$(OBJDUMP) -j .text -j .fartext -h -d -S $(DIR_OBJ)$@ > lst/$...@.lst

If it's possible, what is command line to get fully mixed code ?

Thanks for reply.

Regards, Thierry



Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

#5 Dec. 9, 2010 11:29:25

t.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] MSP430X with MSPGCC and MSP430F543XA


Hi,Following my last post, I noticed that libraries (libc) are located
below the "64K" limit, in ".text" section!
My first question is; How to put them inside the ".fartext" section to
save memory space for datas ?Should I recompile all msp430-libc with specify "FAR" attribute to anyfunctions declaration ?I use Objdump to see what the compiler does ! In the ".text" section I
have all mixed informations : source and disassemby language, but on
".fartext" section I have only disassembly language !It's seem that there is a confusion between ".text" and ".fartext"addresses in objdump (binutils)!To see what's happen, I force the start ".fartext" section address at0x15C00 (0x5C00 + 0x10000) !I made a example :

In lower memory space:
0x05C36 : My_Asm_add_function_in_text
0x05C3A : My_C_sub_function_in_text

In upper memory space:
0x15C00 :My_Asm_add_function_in_fartext
0x15C04 : My_C_sub_function_in_fartext
0x15C08 : mainI have all mixed Informations on both section at same place for lowermemory and only disassembly language for high memory !Disassembly of section .text:

00005c00 <__init_stack>:
5c00: 31 40 ee 5b mov #23534, r1 ;#0x5bee

00005c04 <__low_level_init>:
return a - b;
}

CODE
int My_C_sub_function_in_fartext(int a, int b)
{
5c04: b2 40 80 5a mov #23168, &0x015c ;#0x5a80
5c08: 5c 01

00005c0a <__do_clear_bss>:
}


CODE
int main(void)
{
5c0a: 3f 40 00 00 mov #0, r15 ;#0x0000
int volatile a = 10, b = 20;
5c0e: 0f 93 tst r15
5c10: 04 24 jz $+10 ;abs 0x5c1a
5c12: 1f 83 dec r155c14: cf 43 00 1c mov.b #0, 7168(r15);r3 As==00,0x1c00(r15)while (1)
{
// main loop
a = My_Asm_add_function_in_text(a, b);
5c18: fc 23 jnz $-6 ;abs 0x5c12

00005c1a <__do_copy_data>:
5c1a: 3f 40 00 00 mov #0, r15 ;#0x0000
5c1e: 0f 93 tst r15
5c20: 06 24 jz $+14 ;abs 0x5c2e
5c22: 2f 83 decd r155c24: 40 18 9f 4f movx 23616(r15),7168(r15);0x05c40(r15),0x01c00(r15)5c28: 40 5c 00 1c

a = My_C_sub_function_in_text(a, b);
5c2c: fa 23 jnz $-10 ;abs 0x5c22

00005c2e <__jump_to_main>:
5c2e: 80 01 08 5c bra #0x15c08

00005c32 <__ctors_end>:
5c32: 80 00 3e 5c bra #0x05c3e

00005c36 <My_Asm_add_function_in_text>:

b = My_Asm_add_function_in_fartext(a, b);
5c36: 0f 5e add r14, r15
5c38: 10 01 reta

00005c3a <My_C_sub_function_in_text>:
int My_Asm_add_function_in_fartext(int a, int b);


int My_C_sub_function_in_text(int a, int b)
{
return a - b;
5c3a: 0f 8e sub r14, r15
}
5c3c: 10 01 reta

00005c3e <_unexpected_>:
5c3e: 00 13 reti

Disassembly of section .fartext:

00015c00 <My_Asm_add_function_in_fartext>:
15c00: 0f 5e add r14, r15
15c02: 10 01 reta

00015c04 <My_C_sub_function_in_fartext>:
15c04: 0f 8e sub r14, r15
15c06: 10 01 reta

00015c08 <main>:
15c08: 31 40 ea 5b mov #23530, r1 ;#0x5bea
15c0c: b1 40 0a 00 mov #10, 0(r1) ;#0x000a, 0x0000(r1)
15c10: 00 00
15c12: b1 40 14 00 mov #20, 2(r1) ;#0x0014, 0x0002(r1)
15c16: 02 00
15c18: 1e 41 02 00 mov 2(r1), r14 ;0x0002(r1)
15c1c: 2f 41 mov @r1, r15
15c1e: b0 13 36 5c calla #0x05c36
15c22: 81 4f 00 00 mov r15, 0(r1) ;0x0000(r1)
15c26: 1e 41 02 00 mov 2(r1), r14 ;0x0002(r1)
15c2a: 2f 41 mov @r1, r15
15c2c: b0 13 3a 5c calla #0x05c3a
15c30: 81 4f 00 00 mov r15, 0(r1) ;0x0000(r1)
15c34: 1e 41 02 00 mov 2(r1), r14 ;0x0002(r1)
15c38: 2f 41 mov @r1, r15
15c3a: b1 13 00 5c calla #0x15c00
15c3e: 81 4f 02 00 mov r15, 2(r1) ;0x0002(r1)
15c42: 1e 41 02 00 mov 2(r1), r14 ;0x0002(r1)
15c46: 2f 41 mov @r1, r15
15c48: b1 13 04 5c calla #0x15c04
15c4c: 81 4f 02 00 mov r15, 2(r1) ;0x0002(r1)
15c50: e3 3f jmp $-56 ;abs 0x5c18



Regards, Thierry
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

#6 Dec. 10, 2010 01:10:29

k.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] MSP430X with MSPGCC and MSP430F543XA


To solve the far function pointer issue I have developed a set of macros
shown below:

/*
* far.h by Robert Kavaler 1/31/2010
*
* The MSPGCC MSP430X compiler currently does not handle pointers to
functions
* correctly. The compiler treats all pointers as 16 bits, but pointers
* to functions should be 20 bits. As a workaround to handle pointers to
* functions, a set of wrapper macros was developed.
* The macro _FAR is merely shorthand for the far attribute.
* The macro _FARDEF(t, x, p) creates a wrapper function
* x_inlowmem for the function x. It also acts as the formal declaration of
* the actual function. t is the type and p a list of parameter for
* the C declaration of the wrapper function. The wrapper function itself
* is merely a branch to the actual function. The wrapper function always
* lives in the lower 64K address space so it can be accessed/referenced
with
* a 16 bit pointer.
* The macro _FARREF(x) is used to reference the wrapped
* function in C. It is basically the 16 bit address reference of the
* branch instruction that branches to the 20 bit function x.
* The macro _FARDEFH(t, x, p) creates a definition for
* both the far function and the wrapper function for use in header files.
* Example:
* _FARDEFH(void, complicatedStuff, (char *s, int *y));
* _FARDEF(void, complicatedStuff, (char *s, int *y)) { function code }
* void (*func)(char *, int *y) = _FARREF(complicatedStuff);
*/

#ifdef MSP430X5

#define _FAR __attribute__ ((far))
#define _FARREF(x) x ## _inlowmem
#define _FARDEF(t, x, p) t x ## _inlowmem p; \
asm(" .text\n" #x "_inlowmem: bra #"
#x\

"\n\t.section\t.fartext,\"ax\",@progbit\
s");\
_FAR t x p
#define _FARDEFH(t, x, p) _FAR t x p; t x ## _inlowmem p

#else

#define _FAR
#define _FARREF(x) x
#define _FARDEF(t, x, p) t x p
#define _FARDEFH(t, x, p) t x p

#endif

--
View this message in context:http://old.nabble.com/MSP430X-with-MSPGCC-and-MSP430F543XA-tp30405079p30422419.htmlSent from the MSP430 gcc - Users mailing list archive at Nabble.com.



Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

#7 Dec. 10, 2010 10:45:00

t.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] MSP430X with MSPGCC and MSP430F543XA


Hi "kavaler",

Thank you for your solution, I try it, an it's works is you declare the
function pointer in local variable !
So, the compiler don't use an indirect instruction (calla r10)

But be careful if your declation is global, the compiler use a fatal
indirect instruction (calla @address), and the program will crash !

For memory :

Address_storage:
.word _Function_Address_Only_16_bit_are_stored_


calla Address_storage ; cause a cash

mov #Address_storage, R15
calla @R15 ; cause a crash

mov #Address_storage, R15
mov @R15, R15
calla R15 ; correct call !

Regards, Thierry



Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

  • Root
  • » MSPGCC
  • » [Mspgcc-users] MSP430X with MSPGCC and MSP430F543XA [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support