Part Number: MSP430FR2355
Other Parts Discussed in Thread: MATHLIB
Hello all,
Iam trying to use the ADC of my MSP430FR2355 LAUNCHPAD to sample the outputs of two SAC i.e. SAC0 & SAC2 using TIMER TRIGGER.
According to User Guide of launchpad, OA0 out can be connected internally to ADC Input & OA20 out needs to be connected to ADC input externally.
I've followed the examples and try writing the below code as shown
/*******************SAC0 configurations ******************/ P1SEL0 |= BIT1|BIT2 ; // Select P1.2 P1.1 AS OA0 OUTPUT OA0- PIN function P1SEL1 |= BIT1| BIT2 ; // Select P1.2 OA0- PIN function SAC0DAC = DACSREF_1; // Select 2.5V int Vref as DAC reference SAC0DAT = 2048; // Set SAC DAC data to 1.25V SAC0DAC |= DACEN; // Enable DAC SAC0OA |= NMUXEN | PMUXEN | PSEL_1 | NSEL_0; //Select positive INPUT AS DAC and negative pin input AS external // SAC0PGA |= MSEL_0; // INVERTING PGA MODE SAC0OA &= ~OAPM; // Select HIGH speed and HIGH power mode SAC0OA |= SACEN + OAEN; // Enable SAC and OA /****************SAC2 configurations AS INVERTING PGA************/ P3SEL0 |= BIT1 ; // Select P3.1 OA2 OUTPUT function P3SEL1 |= BIT1 ; // Select P3.1 OA2 OUTPUT function SAC2DAC = DACSREF_1; // Select 2.5V int Vref as DAC reference SAC2DAT = 2048; // DAC TO PROVIDE BIAS FOR AMPLIFIER SAC2DAC |= DACEN; // Enable DAC SAC2OA |= NMUXEN | PMUXEN | PSEL_1 | NSEL_1;//Select positive INPUT AS DAC and negative pin input AS O/P of OA0 SAC2PGA |= GAIN0 + GAIN2 + MSEL_3; // Set inverting PGA mode with Gain=16 SAC2OA &= ~OAPM; // Select HIGH speed and HIGH power mode SAC2OA |= SACEN | OAEN; // Enable SAC and OA
/***********ADC CONFIGURATION***********/ ADCCTL0 &= ~ADCENC; // Disable ADC ADCCTL0 |= ADCSHT_4 | ADCMSC | ADCON; //0000010010010010; 64 ADCLK CYCLES, MSC BIT HIGH, ADC ON ADCCTL1 |= ADCSHP | ADCSHS_1 | ADCCONSEQ_1|ADCSSEL_1; //0000010010010010; ADCCTL2 &= ~ADCRES; //CLEAR RESOLUTION ADCCTL2 |= ADCRES_2; //12 BIT RESOLUTION ADCMCTL0 |= ADCSREF_1|ADCINCH_1|ADCINCH_3; // OA0 OUTPUT AS A1 ADC INPUT ,VR+= VREF+, ALSO OA2 OUPUT EXTERNALLY CONNECTED TO A3 ADC INPUT ADCIE |= ADCIE0; // ENABLE CONVERSION COMPLETE INTERRUPT __enable_interrupt(); // enable maskables /******************** Configure Timer ******************/ TB0CTL = TBSSEL__ACLK + TBCLR; //ACLK & Reset timer TB0CCTL1 = OUTMOD_2; // TOGGLE & RESET TB0CCTL0 = CCIE; //INTERRUPT ENABLE TB0CCR0 = 31; //SAMPLING RATE 512 SPS TB0CCR1 = 10; //Allow plenty of time for the signal to become stable before sampling TB0CTL |= MC_1; // UP MODE ADCCTL0 |= ADCENC; // ENABLE CONVERSION & START CONVERSION While(1) { } // ADC interrupt service routine written outside main function #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=ADC_VECTOR __interrupt void ADC_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(ADC_VECTOR))) ADC_ISR (void) #else #error Compiler not supported! #endif { ADCIFG &= ~ADCIFG0; // CLEAR INTERRUPT FLAG } // Timer B0 interrupt service routine outside main fucntion #pragma vector=TIMER0_B0_VECTOR __interrupt void Timer0_B0_ISR(void) { x = ADCMEM0; Y= ADCMEM0; }
I tried putting breakpoint in ADC ISR but it never comes inside ADC ISR. Timer ISR is working but X& Y both values are always 1. Both SAC are working as I have check the SAC output on Oscilloscope.
Where am I doing it wrong?

