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.

ADC12A Interrupt Problem in single channel singleconversion

Other Parts Discussed in Thread: MSP430F5438

hi everybody......

I have working in a project using the MSP430 devices. Now at present i am using the MSP430F5438 EM board device for the Analog to digital conversion and displaying the data in the LCD of the board. The problem is that when the program is written without the low power mode and it could read the data in the LCD. Now i reprogrammed the program to configure it in the low power mode in the same program, but the enabled ADC interrupt does not come out of the serivce routine and the data could not be read. 

I need to ask another doubt when configuring the ADC for single channel single conversion, the voltage applied to the ADC input should be done before "switching ON" the board or after "switching ON" the board. what is the time taken for the ADC input to be converted to digital input  and that appears in the LCD display, when configured the ADC module as in the following program:

void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P9OUT |= 0x02; // Set P9.1 to output direction
P9SEL |= 0x0F; // P9.1,2,3 option select
t_int ();
_delay_ms(5000);
halLcdInit();
halLcdClearScreen();
halLcdPrintLine("VEC_LAB",1,0x04);
_delay_ms(2000);

//ADC initilization
unsigned int tp1;
P6SEL |= 0x80;                                            // for selecting the ADC input from Port6.7
P1OUT |= 0x01;
_delay_ms(1000);
REFCTL0 |= REFMSTR+REFVSEL_2+REFON+REFTCOFF;
ADC12CTL0 = ADC12SHT0_7; // Set sample time to 192 cycles
ADC12CTL0 = ADC12ON;
ADC12CTL1 = ADC12CONSEQ_0 + ADC12SSEL_0 + ADC12SHS_0; // Enable single channel & sample
ADC12CTL1 = ADC12CSTARTADD_0; // timer
ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_7;  // ADC input ch A7 => sensor input
ADC12IE = 0x01;
_delay_ms(75);
ADC12CTL0 |= ADC12ENC;
P1OUT &=~0x01;
P1OUT |= 0x02;
_delay_ms(2500);
do
{
ADC12CTL0|= ADC12SC;
halLcdClearScreen();
halLcdPrintLine("Height in Cms",2,0x04);
_BIS_SR(LPM4_bits+GIE);
temp = ADC12MEM0;
_delay_ms(500);
P1OUT |=0x01;
tp1 = temp; // Read the ADC Channel 7 data
ldcstatus(); //chk LCD Busy
segment7_putnum(tp1);
_delay_ms(2500); //Delay
} while(1); // Continously read the ADC Channel 7

}

// ADC interrupt routine
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
switch(__even_in_range(ADC12IV,34))
{
case 0: break; // Vector 0: No interrupt
case 2: break; // Vector 2: ADC overflow
case 4: break; // Vector 4: ADC timing overflow
case 6: // Vector 6: ADC12IFG0
__bic_SR_register_on_exit(LPM4_bits); // Exit active CPU
break;
case 8: break; // Vector 8: ADC12IFG1
case 10: break; // Vector 10: ADC12IFG2
case 12: break; // Vector 12: ADC12IFG3
case 14: break; // Vector 14: ADC12IFG4
case 16: break; // Vector 16: ADC12IFG5
case 18: break; // Vector 18: ADC12IFG6
case 20: break; // Vector 20: ADC12IFG7
case 22: break; // Vector 22: ADC12IFG8
case 24: break; // Vector 24: ADC12IFG9
case 26: break; // Vector 26: ADC12IFG10
case 28: break; // Vector 28: ADC12IFG11
case 30: break; // Vector 30: ADC12IFG12
case 32: break; // Vector 32: ADC12IFG13
case 34: break; // Vector 34: ADC12IFG14
default: break;
}
}

  • Gnana,

    You are putting the device into LPM4 mode. When you do this all of the clocks are turned off. The only way to exit LPM4 is through a GPIO interrupt or a reset. 

    If you use the other LPM modes you will be ok.

    Look at the device user guide and pick the mode that still keeps the clock alive that you are using for the ADC.

    -Jason

     

  • I configured the ADC clock for ACLK and used the low power mode3 for the operation. i just went through the errata note of the msp430f5438 device and found that the "no operation" instruction should be included while exiting from the low power mode and entering into the main program for the next line to be executed. I did the same and made to run in the debugger using the simulator option. The problem is that now in the Interrupt service routine the ADCMEM0 value should be moved to a "volatile long temp" and it is not done.

    I did change the value of ADC MEM0 register in the register window, but no effect.. and the returning from ISR routine is not done, there is some problem.The source file and IAR workbench screen shot that i have used is attached in the zip file.  I am unable to resolve it ... the debugger just blinks at the __no_operation( ); line itself and as in simulator the "forced interrupt option" can be used to exit from the interrupt but it has no effect.. 

    Help me in that ...  

    adc program routine.zip
  • If you put the breakpoint onto the NOP right after entering LPM, this breakpoint is hit before LPM is even entered. So the conversion wasn't done and hte ISR never called at this point. It has to do with the pipelining mechanism that makes the MSP so fast.

    You need to set the breakpoint inside the ISR, or on the instruction after the NOP that follows teh LPM entry.

    In simulator, things own't work, as the ADC hardware of course isn't simulated.

**Attention** This is a public forum