how to set DAC to 2.5V ???

Started by HEX.loader May 5, 2005
hello,


i need to set dac to 2.5V, but dont know how to do it?

its line from example:
DAC12_1DAT = 0x0666;                            // 2.0V

i adopted it to mspgcc and changed it:
DAC12_1DAT_ = 0x0FFF;                            // 2.5V

but dont work. why? compiler shows error exactly on 0x0FFF. so how
mspgcc understand? (it was taken from IAR examples and tried to launch
on mspgcc and only this line dont pass)


i really need help.

Beginning Microcontrollers with the MSP430

The DAC needs a voltage reference of course, this is set with only bits 
13 and 14 on the DAC12_xCTL register. If you set this to 00, or 01, it 
pulls from VRef, which voltage will depend on your ADC settings. (see 
the data sheet about the voltage reference generator in the ADC 
section.) If you set it to 10, or 11 it will pull from the VeREF pin, 
which you will need to insert a voltage from the board. The other 
settings should have to change for merely a voltage reference change.

-Micah



HEX.loader wrote:

> hello,
>
>
> i need to set dac to 2.5V, but dont know how to do it?
>
> its line from example:
> DAC12_1DAT = 0x0666;                            // 2.0V
>
> i adopted it to mspgcc and changed it:
> DAC12_1DAT_ = 0x0FFF;                            // 2.5V
>
> but dont work. why? compiler shows error exactly on 0x0FFF. so how
> mspgcc understand? (it was taken from IAR examples and tried to launch
> on mspgcc and only this line dont pass)
>
>
> i really need help.
>
>
> .
>
>
>
>
> 
> *>.
>
>


hmmm...

but why this line, from examples dir of IAR
DAC12_1DAT = 0x0666;                            // 2.0V
dont work on mspgcc???
here is my example. what is wrong, what I missed here? or its only a
part of program to work? I don't understand why I cant assign 0x0CCC
to DAC12_1DAT_ :(
***************
#include  <msp430x16x.h>

int main(void)
{ 
  WDTCTL = WDTPW + WDTHOLD;                       // Stop watchdog
  ADC12CTL0 = REF2_5V + REFON;                    // Internal 2.5V ref on 
  DAC12_1CTL = DAC12IR + DAC12AMP_5 + DAC12ENC;   // Internal ref gain 1
  DAC12_1DAT_ = 0x0CCC;                            // 1V
  _BIS_SR(LPM4_bits);                             // Enter LPM4 
}
***************

one more question: here is last line. in common.h I've found this:
#define LPM4                SCG1+SCG0+OSCOFF+CPUOFF
and a little bit further:
#define LPM4      _BIS_SR(LPM4_bits)
so, if I'll use instead of the last line LPM4 which line will work
out? or compiler know which line to take or it will take first, or
both, or take first, look if its not need, take second?
what will be if I use instead of the last line just LMP4???



On 5/5/05, Micah <micah@mica...> wrote:
> The DAC needs a voltage reference of course, this is set with only bits
> 13 and 14 on the DAC12_xCTL register. If you set this to 00, or 01, it
> pulls from VRef, which voltage will depend on your ADC settings. (see
> the data sheet about the voltage reference generator in the ADC
> section.) If you set it to 10, or 11 it will pull from the VeREF pin,
> which you will need to insert a voltage from the board. The other
> settings should have to change for merely a voltage reference change.
> 
> -Micah
> 
> 
> HEX.loader wrote:
> 
> > hello,
> >
> >
> > i need to set dac to 2.5V, but dont know how to do it?
> >
> > its line from example:
> > DAC12_1DAT = 0x0666;                            // 2.0V
> >
> > i adopted it to mspgcc and changed it:
> > DAC12_1DAT_ = 0x0FFF;                            // 2.5V
> >
> > but dont work. why? compiler shows error exactly on 0x0FFF. so how
> > mspgcc understand? (it was taken from IAR examples and tried to launch
> > on mspgcc and only this line dont pass)
> >
> >
> > i really need help.
> >
> >
> > .
> >
> >
> >
> >
> > 
> > *>.
> >
> >
> 
> .
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
>

Maybe reason is the silicon bug between SVS and DAC1? 
Do you do not get the voltage or is it a compile error? Or what?

> > > DAC12_1DAT_ = 0x0FFF;                   
        // 2.5V
> > >
> > > but dont work. why? compiler shows error exactly on 0x0FFF. so
how
> > > mspgcc understand? (it was taken from IAR examples and tried to
launch
> > > on mspgcc and only this line dont pass)

A compile error? Drop the last "_"? Search through the #include files
that
DAC12_1DAT is present. (please be more specific, "dont work" can mean
everything)

Multiple #defines: normally you get a warning and the compiler is using the
redefinition. Use option -i (?I am not sure) to run the preprocessor only.
As result you get a c-file with computed macros.

Matthias

On Fri, May 06, 2005 at 09:34:51AM +0200,
HEX.loader wrote:
> hmmm...
> 
> but why this line, from examples dir of IAR
> DAC12_1DAT = 0x0666;                            // 2.0V
> dont work on mspgcc???
> here is my example. what is wrong, what I missed here? or its only a
> part of program to work? I don't understand why I cant assign 0x0CCC
> to DAC12_1DAT_ :(
> ***************
> #include  <msp430x16x.h>
> 
> int main(void)
> { 
>   WDTCTL = WDTPW + WDTHOLD;                       // Stop watchdog
>   ADC12CTL0 = REF2_5V + REFON;                    // Internal 2.5V ref on 
>   DAC12_1CTL = DAC12IR + DAC12AMP_5 + DAC12ENC;   // Internal ref gain 1
>   DAC12_1DAT_ = 0x0CCC;                            // 1V
>   _BIS_SR(LPM4_bits);                             // Enter LPM4 
> }
> ***************
> 
> one more question: here is last line. in common.h I've found this:
> #define LPM4                SCG1+SCG0+OSCOFF+CPUOFF
> and a little bit further:
> #define LPM4      _BIS_SR(LPM4_bits)
> so, if I'll use instead of the last line LPM4 which line will work
> out? or compiler know which line to take or it will take first, or
> both, or take first, look if its not need, take second?
> what will be if I use instead of the last line just LMP4???
> 
> 
> 
> On 5/5/05, Micah <micah@mica...> wrote:
> > The DAC needs a voltage reference of course, this is set with only
bits
> > 13 and 14 on the DAC12_xCTL register. If you set this to 00, or 01, it
> > pulls from VRef, which voltage will depend on your ADC settings. (see
> > the data sheet about the voltage reference generator in the ADC
> > section.) If you set it to 10, or 11 it will pull from the VeREF pin,
> > which you will need to insert a voltage from the board. The other
> > settings should have to change for merely a voltage reference change.
> > 
> > -Micah
> > 
> > 
> > HEX.loader wrote:
> > 
> > > hello,
> > >
> > >
> > > i need to set dac to 2.5V, but dont know how to do it?
> > >
> > > its line from example:
> > > DAC12_1DAT = 0x0666;                            // 2.0V
> > >
> > > i adopted it to mspgcc and changed it:
> > > DAC12_1DAT_ = 0x0FFF;                            // 2.5V
> > >
> > > but dont work. why? compiler shows error exactly on 0x0FFF. so
how
> > > mspgcc understand? (it was taken from IAR examples and tried to
launch
> > > on mspgcc and only this line dont pass)
> > >
> > >
> > > i really need help.
> > >
> > >
> > > .
> > >
> > >
> > >

so, it is so: IAR use macro DAC12_1DAT and mspgcc dont pass it then i
find it in headers macro which fit to mspgcc and its DAC12_1DAT_ .
yes, the problem is that I cant compile this example.
it shows error exactly here:
> > > > DAC12_1DAT_ = 0x0FFF;                            // 2.5V
and write: "invalid lvalue in assignment".
if i write DAC12_1DAT_ ; compiler finish without any errors, so, here
is the main problem - assignment. how to assign such value in mspgcc?

    #define sfrw_(x,x_) \
    volatile unsigned int x asm(#x_)

#define DAC12_1DAT_         0x01CA  /* DAC12 data 1 */
sfrw(DAC12_1DAT,DAC12_1DAT_);

results in
 volatile unsigned int DAC12_1DAT asm(#DAC12_1DAT_);

You should be able to work with DAC12_1DAT 

Matthias

On Fri, May 06, 2005 at 02:57:35PM +0200,
HEX.loader wrote:
> so, it is so: IAR use macro DAC12_1DAT and mspgcc dont pass it then i
> find it in headers macro which fit to mspgcc and its DAC12_1DAT_ .
> yes, the problem is that I cant compile this example.
> it shows error exactly here:
> > > > > DAC12_1DAT_ = 0x0FFF;                            //
2.5V
> and write: "invalid lvalue in assignment".
> if i write DAC12_1DAT_ ; compiler finish without any errors, so, here
> is the main problem - assignment. how to assign such value in mspgcc?
> 
> 

all is ok now ;) thanx a lot!!!

it was made a mistake in dac12.h file thats why dont work. now i
corrected it like u write hear (instead of typing it in source) and
now everything is ok ;)

thanx a lot one more time.


On 5/6/05, Matthias Weingart <msp430@msp4...>
wrote:
>     #define sfrw_(x,x_) \
>     volatile unsigned int x asm(#x_)
> 
> #define DAC12_1DAT_         0x01CA  /* DAC12 data 1 */
> sfrw(DAC12_1DAT,DAC12_1DAT_);
> 
> results in
>  volatile unsigned int DAC12_1DAT asm(#DAC12_1DAT_);
> 
> You should be able to work with DAC12_1DAT
> 
> Matthias
> 
> On Fri, May 06, 2005 at 02:57:35PM +0200, HEX.loader wrote:
> > so, it is so: IAR use macro DAC12_1DAT and mspgcc dont pass it then i
> > find it in headers macro which fit to mspgcc and its DAC12_1DAT_ .
> > yes, the problem is that I cant compile this example.
> > it shows error exactly here:
> > > > > > DAC12_1DAT_ = 0x0FFF;                           
// 2.5V
> > and write: "invalid lvalue in assignment".
> > if i write DAC12_1DAT_ ; compiler finish without any errors, so, here
> > is the main problem - assignment. how to assign such value in mspgcc?
> >
> >
> 
> .
> 
> Yahoo! Groups Links
> 
> 
> 
> 
>