Tool/software: Code Composer Studio
How could I generate sine wave with the help of MSP430FR2355.I am able to get triangular wave with the help of this code but I want to generate the sine wave with the help of the DAC.please suggest me regarding this issues
#include <msp430.h> unsigned int DAC_data=0; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watch dog timer P1SEL0 |= BIT1; // Select P1.1 as OA0O function P1SEL1 |= BIT1; // OA is used as buffer for DAC PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode // to activate previously configured port settings // Configure reference module PMMCTL0_H = PMMPW_H; // Unlock the PMM registers PMMCTL2 = INTREFEN | REFVSEL_2; // Enable internal 2.5V reference while(!(PMMCTL2 & REFGENRDY)); // Poll till internal reference settles SAC0DAC = DACSREF_1 + DACLSEL_2 + DACIE; // Select int Vref as DAC reference SAC0DAT = DAC_data; // Initial DAC data SAC0DAC |= DACEN; // Enable DAC SAC0OA = NMUXEN + PMUXEN + PSEL_1 + NSEL_1;//Select positive and negative pin input SAC0OA |= OAPM; // Select low speed and low power mode SAC0PGA = MSEL_1; // Set OA as buffer mode SAC0OA |= SACEN + OAEN; // Enable SAC and OA // Use TB2.1 as DAC hardware trigger TB2CCR0 = 100-1; // PWM Period/2 TB2CCTL1 = OUTMOD_6; // TBCCR1 toggle/set TB2CCR1 = 50; // TBCCR1 PWM duty cycle TB2CTL = TBSSEL__SMCLK | MC_1 | TBCLR; // SMCLK, up mode, clear TBR __bis_SR_register(LPM3_bits + GIE); // Enter LPM3, Enable Interrupt } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector = SAC0_SAC2_VECTOR __interrupt void SAC0_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(SAC0_SAC2_VECTOR))) SAC0_ISR (void) #else #error Compiler not supported! #endif { switch(__even_in_range(SAC0IV,SACIV_4)) { case SACIV_0: break; case SACIV_2: break; case SACIV_4: DAC_data++; DAC_data &= 0xFFF; SAC0DAT = DAC_data; // DAC12 output positive ramp break; default: break; } }