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;
}
}