Jump to content
43oh

ADC sample capture in one port on MSP430


Recommended Posts

hello friends, 
I have a big problem with small MSP430G2553, I would like to make a capture samples at P1.2 of the microcontroller, 
but my code does not work, what am I doing wrong, can someone help me.
My code:
unsigned int adcValue = 0;
int i, BPM[10];
int maior = BPM[0];
int menor = BPM[0];
int contagem =0;

/*****************************************************************/
/********* LOCAL FUNCTIONS                               *********/
/*****************************************************************/

void ADC_ConfigAnalogInput(void){

    P1DIR2IN(BIT0);

    ADC10CTL0 &= ~(ENC);

    ADC10CTL1  = (INCH_0 + ADC10DIV_0);

    ADC10CTL0  = (SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE);

    ADC10AE0  |= BIT0;

    ADC10CTL0 |= ENC;

}


void ADC_ReadAnalogInput(void){
ADC_ConfigAnalogInput();

while (ADC10CTL1 & BUSY);               // WAIT IF BUSY

ADC10CTL0 |= ADC10SC;

__bis_SR_register(CPUOFF + GIE);        // LPM0, ADC10_ISR will force exit

 adcValue = ADC10MEM;
}



/*

 *

 */

unsigned int ADC_GetValue(void)

{

    return adcValue;
    for (j=0;j<timer; j++){
    BPM[j]=adcValue;
     if(maior < BPM[i]){
            maior = BPM[j];
        }
        if(menor > BPM[j]){
            menor = BPM[j];
        }
}
if(contagem>59)
contagem =0;
else
contagem++;

}

/*****************************************************************/
/********* END                                           *********/
/*****************************************************************/

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...