EmbeddedRelated.com
Forums

CPU autodetection for IAR and Crossworks?

Started by rolf...@... September 28, 2005
Hi,

when i change the target (CPU) in an mspgcc project i only have to change the
CPU     = msp430...
line in makefile but in IAR and Crossworks projects i have to change a) the
project file
(and maybe the solution file) and b) dozens of .c-files because IAR and
Crosswork do need
a cpu specific header, e. g. <MSP430x14x.h>.
To eleminate this redundancy and non-orthogonality i do need a CPU autodetection
from the preprocessor in the primary header file, something like

#ifdef __MSP430_W427__
[include the header(s) for MSP430W427]
#endif

Is this possible with IAR and Crossworks?

Regards,

Rolf


Beginning Microcontrollers with the MSP430

>when i change the target (CPU) in an mspgcc project
i only have to change the
>CPU     = msp430...
>line in makefile but in IAR and Crossworks projects i have to change a) the
project file
>(and maybe the solution file) and b) dozens of .c-files because IAR and
Crosswork do need
>a cpu specific header, e. g. <MSP430x14x.h>.
>To eleminate this redundancy and non-orthogonality i do need a CPU
autodetection
>from the preprocessor in the primary header file, something like
>
>#ifdef __MSP430_W427__
>[include the header(s) for MSP430W427]
>#endif
>
>Is this possible with IAR and Crossworks?
>  
>

Hi Rolf!

Sure it's possible, but you have to do all the work yourself.

Maybe you could model it on how gcc does things, does it define symbols 
that corresponds to the different cpu derivates that it supports? In 
that case you could simply define them on the command line (or in GUI) 
and act as though you would using gcc.

Unfortunately, in Embedded Workbench there is no connection from the cpu 
derivates drop down list to the compiler, so you won't get away from 
having to specify the cpu variant somehow. The drop-down list only 
controls the linker command file and the avaiability of some options.

    -- Anders Lindgren, IAR Systems
-- 
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.


Rolf, 

> when i change the target (CPU) in an mspgcc
project i only 
> have to change the
> CPU     = msp430...
> line in makefile but in IAR and Crossworks projects i have to 
> change a) the project file (and maybe the solution file) and 
> b) dozens of .c-files because IAR and Crosswork do need a cpu 
> specific header, e. g. <MSP430x14x.h>.
> To eleminate this redundancy and non-orthogonality i do need 
> a CPU autodetection from the preprocessor in the primary 
> header file, something like
> 
> #ifdef __MSP430_W427__
> [include the header(s) for MSP430W427]
> #endif
> 
> Is this possible with IAR and Crossworks?

Take a look at <msp430.h> in CrossWorks.  If you define the preprocessor
symbol __TARGET_PROCESSOR to be (for instance) MSP430FW427 then you'll
get the FW427 definitions when #including <msp430.h>.
__TARGET_PROCESSOR is set by the project system, but you can set it on
the command line if you use command line tools.

--
Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
CrossWorks for MSP430, ARM, AVR and now MAXQ processors

Paul,

ok, when i change 
#  include <msp430x14x.h>
to
#  include <msp430.h> 
it seems to work, but why are the examples using specific headers
like
#  include <msp430x14x.h>
and not simply
#  include <msp430.h> 
?

Regards,

Rolf
------------------------
www.true-random.com

msp430@msp4... schrieb am 28.09.05 11:16:05:
> 
> Rolf, 
> 
> > when i change the target (CPU) in an mspgcc project i only 
> > have to change the
> > CPU     = msp430...
> > line in makefile but in IAR and Crossworks projects i have to 
> > change a) the project file (and maybe the solution file) and 
> > b) dozens of .c-files because IAR and Crosswork do need a cpu 
> > specific header, e. g. <MSP430x14x.h>.
> > To eleminate this redundancy and non-orthogonality i do need 
> > a CPU autodetection from the preprocessor in the primary 
> > header file, something like
> > 
> > #ifdef __MSP430_W427__
> > [include the header(s) for MSP430W427]
> > #endif
> > 
> > Is this possible with IAR and Crossworks?
> 
> Take a look at <msp430.h> in CrossWorks.  If you define the
preprocessor
> symbol __TARGET_PROCESSOR to be (for instance) MSP430FW427 then you'll
> get the FW427 definitions when #including <msp430.h>.
> __TARGET_PROCESSOR is set by the project system, but you can set it on
> the command line if you use command line tools.
> 
> --
> Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
> CrossWorks for MSP430, ARM, AVR and now MAXQ processors




Hi Rolf,

Those examples come straight from TI with those #includes left intact.
They work on IAR and CrossWorks and they work (IIRC) on Quadravox.

Regards,

--
Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
CrossWorks for MSP430, ARM, AVR and now MAXQ processors 

> -----Original Message-----
> From: rolf.freitag@rolf... [mailto:rolf.freitag@rolf...] 
> Sent: 28 September 2005 15:19
> To: msp430@msp4...
> Subject: RE: [msp430] CPU autodetection for IAR and Crossworks?
> 
> 
> Paul,
> 
> ok, when i change
> #  include <msp430x14x.h>
> to
> #  include <msp430.h>
> it seems to work, but why are the examples using specific 
> headers like #  include <msp430x14x.h> and not simply #  
> include <msp430.h> ?
> 
> Regards,
> 
> Rolf
> ------------------------
> www.true-random.com
> 
> msp430@msp4... schrieb am 28.09.05 11:16:05:
> > 
> > Rolf,
> > 
> > > when i change the target (CPU) in an mspgcc project i 
> only have to 
> > > change the
> > > CPU     = msp430...
> > > line in makefile but in IAR and Crossworks projects i 
> have to change 
> > > a) the project file (and maybe the solution file) and
> > > b) dozens of .c-files because IAR and Crosswork do need a cpu 
> > > specific header, e. g. <MSP430x14x.h>.
> > > To eleminate this redundancy and non-orthogonality i do 
> need a CPU 
> > > autodetection from the preprocessor in the primary header file, 
> > > something like
> > > 
> > > #ifdef __MSP430_W427__
> > > [include the header(s) for MSP430W427] #endif
> > > 
> > > Is this possible with IAR and Crossworks?
> > 
> > Take a look at <msp430.h> in CrossWorks.  If you define the 
> > preprocessor symbol __TARGET_PROCESSOR to be (for instance) 
> > MSP430FW427 then you'll get the FW427 definitions when 
> #including <msp430.h>.
> > __TARGET_PROCESSOR is set by the project system, but you 
> can set it on 
> > the command line if you use command line tools.
> > 
> > --
> > Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk 
> CrossWorks 
> > for MSP430, ARM, AVR and now MAXQ processors
> 
> 
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> --------------------~--> Fair play? Video games influencing 
> politics. Click and talk back!
> http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/CFFolB/TM
> --------------------------
> ------~-> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 

Why can't the IDE read the 430 Product ID register ( I just assume
that
there is one)
and then set the environment accordingly ?

Alex


----- Original Message ----- 
From: "Anders Lindgren" <Anders.lindgren@Ande...>
To: <msp430@msp4...>
Sent: Wednesday, September 28, 2005 5:09 AM
Subject: Re: [msp430] CPU autodetection for IAR and Crossworks?


>
> >when i change the target (CPU) in an mspgcc project i only have to
change
the
> >CPU     = msp430...
> >line in makefile but in IAR and Crossworks projects i have to change a)
the project file
> >(and maybe the solution file) and b) dozens of
.c-files because IAR and
Crosswork do need
> >a cpu specific header, e. g.
<MSP430x14x.h>.
> >To eleminate this redundancy and non-orthogonality i do need a CPU
autodetection
> >from the preprocessor in the primary header
file, something like
> >
> >#ifdef __MSP430_W427__
> >[include the header(s) for MSP430W427]
> >#endif
> >
> >Is this possible with IAR and Crossworks?
> >
> >
>
> Hi Rolf!
>
> Sure it's possible, but you have to do all the work yourself.
>
> Maybe you could model it on how gcc does things, does it define symbols
> that corresponds to the different cpu derivates that it supports? In
> that case you could simply define them on the command line (or in GUI)
> and act as though you would using gcc.
>
> Unfortunately, in Embedded Workbench there is no connection from the cpu
> derivates drop down list to the compiler, so you won't get away from
> having to specify the cpu variant somehow. The drop-down list only
> controls the linker command file and the avaiability of some options.
>
>     -- Anders Lindgren, IAR Systems
> -- 
> Disclaimer: Opinions expressed in this posting are strictly my own and
> not necessarily those of my employer.
>
>
>
>
> .
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
> ---
> avast! Antivirus: Inbound message clean.
> Virus Database (VPS): 0538-7, 09/23/2005
> Tested on: 9/28/2005 10:39:57 AM
> avast! - copyright (c) 1988-2005 ALWIL Software.
> http://www.avast.com
>
>
>


Hi Alex,

i mean top-down CPU autodetection: The CPU is set in makefile of a similar
file AT ONE PLACE and therefore it's possible that the
preprocessor/compiler/assembler/linker
can work without looking into the source code.
With IAR and the examples from TI you have got the problem that the CPU is
set at many places and even in the source code, so setting the CPU under IAR
is neither orthogonal nor without redundance and it can be done inconsistent.

You mean bottom-up CPU autodetection: The CPU hardware is detected 
and the project is changed for this CPU. With IAR that would be ugly because 
it means that a change of the hardware would change the C/Assembler source!
But it would make sense for workarounds for CPU specific bugs.

Regards,

Rolf


msp430@msp4... schrieb am 28.09.05 18:06:21:
> 
> Why can't the IDE read the 430 Product ID register ( I just assume
that
> there is one)
> and then set the environment accordingly ?
> 
> Alex
> 
> 
> ----- Original Message ----- 
> From: "Anders Lindgren" <Anders.lindgren@Ande...>
> To: <msp430@msp4...>
> Sent: Wednesday, September 28, 2005 5:09 AM
> Subject: Re: [msp430] CPU autodetection for IAR and Crossworks?
> 
> 
> >
> > >when i change the target (CPU) in an mspgcc project i only have to
change
> the
> > >CPU     = msp430...
> > >line in makefile but in IAR and Crossworks projects i have to
change a)
> the project file
> > >(and maybe the solution file) and b) dozens of .c-files because
IAR and
> Crosswork do need
> > >a cpu specific header, e. g. <MSP430x14x.h>.
> > >To eleminate this redundancy and non-orthogonality i do need a CPU
> autodetection
> > >from the preprocessor in the primary header file, something like
> > >
> > >#ifdef __MSP430_W427__
> > >[include the header(s) for MSP430W427]
> > >#endif
> > >
> > >Is this possible with IAR and Crossworks?
> > >
> > >
> >
> > Hi Rolf!
> >
> > Sure it's possible, but you have to do all the work yourself.
> >
> > Maybe you could model it on how gcc does things, does it define
symbols
> > that corresponds to the different cpu derivates that it supports? In
> > that case you could simply define them on the command line (or in GUI)
> > and act as though you would using gcc.
> >
> > Unfortunately, in Embedded Workbench there is no connection from the
cpu
> > derivates drop down list to the compiler, so you won't get away
from
> > having to specify the cpu variant somehow. The drop-down list only
> > controls the linker command file and the avaiability of some options.
> >
> >     -- Anders Lindgren, IAR Systems
> > -- 
> > Disclaimer: Opinions expressed in this posting are strictly my own and
> > not necessarily those of my employer.
> >
> >
> >
> >
> > .
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > ---
> > avast! Antivirus: Inbound message clean.
> > Virus Database (VPS): 0538-7, 09/23/2005
> > Tested on: 9/28/2005 10:39:57 AM
> > avast! - copyright (c) 1988-2005 ALWIL Software.
> > http://www.avast.com
> >
> >
> >
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 



----- Original Message ----- 
From: <rolf.freitag@rolf...>
To: <msp430@msp4...>
Sent: Wednesday, September 28, 2005 2:17 PM
Subject: Re: [msp430] CPU autodetection for IAR and Crossworks?


>
> Hi Alex,
>
> i mean top-down CPU autodetection: The CPU is set in makefile of a similar
> file AT ONE PLACE and therefore it's possible that the
preprocessor/compiler/assembler/linker
> can work without looking into the source code.

Isn't this done with "ifdef" s ?
Alex


Is that register accessible from a running program, i mean can we 
produce a binary that looks at the product id register at runtime? I 
could not find this information until now.

Dieter Teuchert

alex@alex... wrote:

>Why can't the IDE read the 430 Product ID
register ( I just assume that
>there is one)
>and then set the environment accordingly ?
>
>Alex
>
>
>----- Original Message ----- 
>From: "Anders Lindgren" <Anders.lindgren@Ande...>
>To: <msp430@msp4...>
>Sent: Wednesday, September 28, 2005 5:09 AM
>Subject: Re: [msp430] CPU autodetection for IAR and Crossworks?
>
>
>  
>
>>>when i change the target (CPU) in an mspgcc project i only have to
change
>>>      
>>>
>the
>  
>
>>>CPU     = msp430...
>>>line in makefile but in IAR and Crossworks projects i have to change
a)
>>>      
>>>
>the project file
>  
>
>>>(and maybe the solution file) and b) dozens of .c-files because IAR
and
>>>      
>>>
>Crosswork do need
>  
>
>>>a cpu specific header, e. g. <MSP430x14x.h>.
>>>To eleminate this redundancy and non-orthogonality i do need a CPU
>>>      
>>>
>autodetection
>  
>
>>>from the preprocessor in the primary header file, something like
>>    
>>
>>>#ifdef __MSP430_W427__
>>>[include the header(s) for MSP430W427]
>>>#endif
>>>
>>>Is this possible with IAR and Crossworks?
>>>
>>>
>>>      
>>>
>>Hi Rolf!
>>
>>Sure it's possible, but you have to do all the work yourself.
>>
>>Maybe you could model it on how gcc does things, does it define symbols
>>that corresponds to the different cpu derivates that it supports? In
>>that case you could simply define them on the command line (or in GUI)
>>and act as though you would using gcc.
>>
>>Unfortunately, in Embedded Workbench there is no connection from the cpu
>>derivates drop down list to the compiler, so you won't get away
from
>>having to specify the cpu variant somehow. The drop-down list only
>>controls the linker command file and the avaiability of some options.
>>
>>    -- Anders Lindgren, IAR Systems
>>-- 
>>Disclaimer: Opinions expressed in this posting are strictly my own and
>>not necessarily those of my employer.
>>
>>
>>
>>
>>.
>>
>>
>>Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>---
>>avast! Antivirus: Inbound message clean.
>>Virus Database (VPS): 0538-7, 09/23/2005
>>Tested on: 9/28/2005 10:39:57 AM
>>avast! - copyright (c) 1988-2005 ALWIL Software.
>>http://www.avast.com
>>
>>
>>
>>    
>>
>
>
>
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>  
>





Read location 0x0ff0, IIRC. 

--
Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
CrossWorks for MSP430, ARM, AVR and now MAXQ processors

> -----Original Message-----
> From: Dieter Teuchert [mailto:dieter@diet...] 
> Sent: 29 September 2005 09:03
> To: msp430@msp4...
> Subject: Re: [msp430] CPU autodetection for IAR and Crossworks?
> 
> Is that register accessible from a running program, i mean 
> can we produce a binary that looks at the product id register 
> at runtime? I could not find this information until now.
> 
> Dieter Teuchert
> 
> alex@alex... wrote:
> 
> >Why can't the IDE read the 430 Product ID register ( I just 
> assume that 
> >there is one) and then set the environment accordingly ?
> >
> >Alex
> >
> >
> >----- Original Message -----
> >From: "Anders Lindgren" <Anders.lindgren@Ande...>
> >To: <msp430@msp4...>
> >Sent: Wednesday, September 28, 2005 5:09 AM
> >Subject: Re: [msp430] CPU autodetection for IAR and Crossworks?
> >
> >
> >  
> >
> >>>when i change the target (CPU) in an mspgcc project i only have
to 
> >>>change
> >>>      
> >>>
> >the
> >  
> >
> >>>CPU     = msp430...
> >>>line in makefile but in IAR and Crossworks projects i have 
> to change 
> >>>a)
> >>>      
> >>>
> >the project file
> >  
> >
> >>>(and maybe the solution file) and b) dozens of .c-files 
> because IAR 
> >>>and
> >>>      
> >>>
> >Crosswork do need
> >  
> >
> >>>a cpu specific header, e. g. <MSP430x14x.h>.
> >>>To eleminate this redundancy and non-orthogonality i do need a
CPU
> >>>      
> >>>
> >autodetection
> >  
> >
> >>>from the preprocessor in the primary header file, something
like
> >>    
> >>
> >>>#ifdef __MSP430_W427__
> >>>[include the header(s) for MSP430W427] #endif
> >>>
> >>>Is this possible with IAR and Crossworks?
> >>>
> >>>
> >>>      
> >>>
> >>Hi Rolf!
> >>
> >>Sure it's possible, but you have to do all the work yourself.
> >>
> >>Maybe you could model it on how gcc does things, does it define 
> >>symbols that corresponds to the different cpu derivates that it 
> >>supports? In that case you could simply define them on the command 
> >>line (or in GUI) and act as though you would using gcc.
> >>
> >>Unfortunately, in Embedded Workbench there is no connection 
> from the 
> >>cpu derivates drop down list to the compiler, so you won't get
away 
> >>from having to specify the cpu variant somehow. The drop-down list 
> >>only controls the linker command file and the avaiability 
> of some options.
> >>
> >>    -- Anders Lindgren, IAR Systems
> >>--
> >>Disclaimer: Opinions expressed in this posting are strictly 
> my own and 
> >>not necessarily those of my employer.
> >>
> >>
> >>
> >>
> >>.
> >>
> >>
> >>Yahoo! Groups Links
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>---
> >>avast! Antivirus: Inbound message clean.
> >>Virus Database (VPS): 0538-7, 09/23/2005 Tested on: 
> 9/28/2005 10:39:57 
> >>AM avast! - copyright (c) 1988-2005 ALWIL Software.
> >>http://www.avast.com
> >>
> >>
> >>
> >>    
> >>
> >
> >
> >
> >
> >.
> >
> > 
> >Yahoo! Groups Links
> >
> >
> >
> > 
> >
> >
> >
> >  
> >
> 
> 
> 
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> --------------------~--> Get Bzzzy! (real tools to help you 
> find a job). Welcome to the Sweet Life.
> http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/CFFolB/TM
> --------------------------
> ------~-> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 
>