Hi Roman,

yes, adding the attribute puts the functions into FARTEXT. But that's not all. 
You must be very careful to not mix (and mess up) things.
Interrupt functions must be near, as the interrupt vectors have only 16 bit. 
(luckily, the additional address bits are stored in unused status register bits 
and therefore saved on interrupt call).
I guess, the compiler will generate FAR calls and returns for any other 
function (else it would be difficult to track which function can be called from 
where). Since 'near' functions can only be called from other near 
functions (their normal 'ret' return code will not poperly return to a far 
function)
But that's not all, there are issues when accessing near memory (such as the 
config memory) from within a function in FARTEXT (look at the device errata 
sheets e.g. for the 5438), problems with the power-down 
mechanism and much more.
Not to mention the fact that far function calls are a tad slower and require 
more memory than the standard near calls.

So yes, it is possible, but it is full of possible problems. And in this case I 
didn't want to go thus far when there was apparently no knowledge at all about 
the MSP430X. Since his project already touched the 64K 
boundary, it is obviously more complex than a simple 'hello world' and 
therefore prone to excessive problems with MSP430X.

AFAIK the far attribute is just an alias for the segment FARTEXT attribute. So 
the compiler will not solve any of the above problems other than just placing 
the code in the FARTEXT segment and generating 430X 
entry/exit code and calls. That's not enough if you don't exactly know what 
you're doing. But maybe the MSP430X branch has made some progress that wasn't 
discussed here (or I missed it).

JMGross


----- Ursprüngliche Nachricht -----
Von: Roman Lim
An: [email protected]
Gesendet am: 12 Jan 2010 09:50:21
Betreff: Re: [Mspgcc-users] section .text will not fit in region text

about MSP430X branch: putting code to fartext works, just add
__attribute((__far__)) to your function definitions. without any
hand-crafted assembly code you can spread your code to both memory
ranges using the c compiler.

roman


Reply via email to