This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F2618: Problem with DAC12_0DAT

Part Number: MSP430F2618
Other Parts Discussed in Thread: MSP430F1611,

Hello

I am trying to replace the old MSP430F1611 with a MSP430F2618.

I am using ImageCraft IDE for ICC430 with NoICE430.

From the old code i was using seems everything to work as intended after small modifications but i can't get to work the DAC12_0DAT It's compyling but the level doesn't change.

I reduced my code to leave only the DAC12_0DAT part of it and it's still not working.

I am now trying to get this code to work :

#include <msp430x26x.h>									 // MSP430F155 Bibliothek

int main(void)
{  
  
  WDTCTL = WDTPW + WDTHOLD;                 			 // Watchdog ausschalten
  

  BCSCTL1 = CALBC1_16MHZ;
  DCOCTL = CALDCO_16MHZ;

  ADC12CTL0 = REF2_5V + REFON;           				 // Interne 2.5V Referenz ein
  DAC12_0CTL = DAC12IR + DAC12AMP_5 + DAC12ENC;			 // Interne Referenz Verstärkung = 1
  DAC12_0DAT = 1500;

  while(1)
  {   
	   	if(DAC12_0DAT>4000) 
		{
			DAC12_0DAT=0;
		}
		DAC12_0DAT=DAC12_0DAT+1;
  }
  return 0;
}

But the only thing i get is a 2,355 V output.

Thanks,

Simon

  • Hi Simond,

    Please refer to DAC code example attached.

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430x26x Demo - DAC12_0, Output 1.0V on DAC0
    //
    //   Description: Using DAC12_0 and 2.5V ADC12REF reference with a gain of 1,
    //   output 1V on P6.6.
    //
    //
    //                MSP430x261x
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |        DAC0/P6.6|--> 1V
    //            |                 |
    //
    //   B. Nisarga
    //   Texas Instruments Inc.
    //   September 2007
    //   Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      ADC12CTL0 = REF2_5V + REFON;              // Internal 2.5V ref on
      TACCR0 = 13600;                           // DELAY to allow Ref to settle
      TACCTL0 |= CCIE;                          // Compare-mode interrupt.
      TACTL = TACLR + MC_1 + TASSEL_2;          // up mode, SMCLK
      __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, enable interrupts
      TACCTL0 &= ~CCIE;                         // Disable timer interrupt
      __disable_interrupt();                    // Disable Interrupts
      DAC12_0CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1
      DAC12_0DAT = 0x0666;                      // 1.0V (2.5V = 0x0FFFh)
      __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0
    }
    
    //DELAY to allow Ref to settle
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = TIMERA0_VECTOR
    __interrupt void TA0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMERA0_VECTOR))) TA0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      TACTL = 0;                                // Clear Timer_A control registers
      __bic_SR_register_on_exit(LPM0_bits);     // Exit LPMx, interrupts enabled
    }
    
    
    
    

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430x26x Demo - DAC12_1, Output 2.0V on DAC1
    //
    //   Description: Using DAC12_1 and 2.5V ADC12REF reference with a gain of 1,
    //   output 2V on P6.7.
    //
    //
    //                MSP430F261x
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |        DAC1/P6.7|--> 2V
    //            |                 |
    //
    //   B. Nisarga
    //   Texas Instruments Inc.
    //   September 2007
    //   Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      ADC12CTL0 = REF2_5V + REFON;              // Internal 2.5V ref on
      TACCR0 = 13600;                           // Delay to allow Ref to settle
      TACCTL0 |= CCIE;                          // Compare-mode interrupt.
      TACTL = TACLR + MC_1 + TASSEL_2;          // up mode, SMCLK
      __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, enable interrupts
      TACCTL0 &= ~CCIE;                         // Disable timer interrupt
      __disable_interrupt();                    // Disable Interrupts
      DAC12_1CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1
      DAC12_1DAT = 0x0CCC;                      // 2.0V (2.5V = 0x0FFFh)
      __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0
    }
    
    // DELAY ISR
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = TIMERA0_VECTOR
    __interrupt void TA0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMERA0_VECTOR))) TA0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      TACTL = 0;                                // Clear Timer_A control registers
      __bic_SR_register_on_exit(LPM0_bits);     // Exit LPMx, interrupts enabled
    }
    

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430x26x Demo - DAC12_0, Output Voltage Ramp on DAC0
    //
    //   Description: Using DAC12_0 and 2.5V ADC12REF reference with a gain of 1,
    //   output positive ramp on P6.6. Normal mode is LPM0 with CPU off.  WDT used
    //   to provide ~0.5ms interrupt used to wake up the CPU and update the DAC
    //   with software. Use internal 2.5V Vref.
    //   ACLK = 32kHz, SMCLK = MCLK = WDTCLK = default DCO 1048576Hz
    //
    //
    //                MSP430F261x
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |        DAC0/P6.6|--> Ramp_positive
    //            |                 |
    //
    //   B. Nisarga
    //   Texas Instruments Inc.
    //   September 2007
    //   Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDT_MDLY_0_064;                  // WDT ~0.064ms interval timer
      IE1 |= WDTIE;                             // Enable WDT interrupt
      ADC12CTL0 = REF2_5V + REFON;              // Internal 2.5V ref on
      TACCR0 = 13600;                           // Delay to allow Ref to settle
      TACCTL0 |= CCIE;                          // Compare-mode interrupt.
      TACTL = TACLR + MC_1 + TASSEL_2;          // up mode, SMCLK
      __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, enable interrupts
      TACCTL0 &= ~CCIE;                         // Disable timer interrupt
      __disable_interrupt();                    // Disable Interrupts
      DAC12_0CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1
    
      while (1)
      {
        __bis_SR_register(LPM0_bits + GIE);     // Enter LPM0, interrupts enabled
        DAC12_0DAT++;                           // Positive ramp
        DAC12_0DAT &= 0x0FFF;
      }
    }
    
    // DELAY ISR
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = TIMERA0_VECTOR
    __interrupt void TA0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMERA0_VECTOR))) TA0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      TACTL = 0;                                // Clear Timer_A control registers
      __bic_SR_register_on_exit(LPM0_bits);     // Exit LPMx, interrupts enabled
    }
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = WDT_VECTOR
    __interrupt void WDT_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(WDT_VECTOR))) WDT_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      __bic_SR_register_on_exit(LPM0_bits);      // TOS = clear LPM0
    }
    

    Ling

  • It always gives me:

     "#error" executed (Compiler not supported!)

  • The 3 exemple you gave me are now working.

    But some part of the code that I was using before doesn't work anymore :

    #pragma interrupt_handler risingEdge:PORT1_VECTOR
    #pragma interrupt_handler Contact:TIMERA0_VECTOR
    
    void risingEdge(void)
    {
        if(P1IFG & BIT7)                                     // Wenn Flag gesetzt ist
        {
            TACTL = 0;                                       // TimerA stoppen
            TACTL |= TACLR;                                  // Clock zuruecksetzen
            CCTL0 = CCIE;                                    // Interrupt
            CCR0 = TIMER_INTERRUPT;                          // Zeit festlegen
            TACTL = TASSEL_2 + MC_1;                         // SMCLK, up-mode
        }
        P1IFG = P1IFG & (~BIT7);                             //Interrupt Flag loeschen
        //...
    }
    
    void Contact(void)
    {
        //...
        TACTL = 0;                                           // TimerA stoppen
        TACTL |= TACLR;                                      // Clock zuruecksetzen
        CCTL0 = CCIE;                                        // Interrupt
        CCR0 = TIMER_INTERRUPT;                              // Zeit festlegen
        TACTL = TASSEL_2 + MC_1;                             // SMCLK, up-mode
        //...
    }

    The code that I posted on my first post doesn't work too.

  • Thanks for youre help but I still don't get why my code (from original post) doesn't work.

    Am I forced to use LPM0 ?

  • Hi SimonD,

    What do you mean doesn't work?

    You have to understand your orignal source code first then you can porting the code to new device, take the example code of new device as a reference. 

    Ling

  • Hi Ling,

    Actually my code from the start work if we remove thoose 2 lines :

    BCSCTL1 = CALBC1_16MHZ;
    DCOCTL = CALDCO_16MHZ;

    and your exemple : MSP430x261x_dac12_03.c

    Doesn't work too if we add thoose 2 lines.

    So I will probably stay with my old Processor.

    Thanks for your help !

  • Hi SimonD,

    BCSCTL1 = CALBC1_16MHZ;
    DCOCTL = CALDCO_16MHZ;

    is setting the system clock to 16MHz.

    You need to configure your system clock and DAC clock to make it work right

    Ling

  • And it's too fast for it.

    Do you have an idea what is the fastest clock setting I can use with it ?

  • Hi SimonD,

    You can configure system clock from 1MHz to 16MHz,  refer to Chapter 5 of document http://www.ti.com/lit/ug/slau144j/slau144j.pdf
    and you can set peripheral clock for DAC. Chapter 25 of http://www.ti.com/lit/ug/slau144j/slau144j.pdf

    Ling

  • Hi Ling,

    I've already tried out to configure the system clock from 1MHz to 16 MHz witout any results.

    I don't understand what you mean with "set peripheral clock for DAC".

    Thanks

    Simon

  • Hi Simon,

    Refer to the DAC code examples I attached in the previous post.

    Ling

**Attention** This is a public forum