본문 바로가기

[MSP430]/MSP430_FRAM

MSP430FR5739 EVM - ADC테스트 (전압값에 따라 게이지 그래프 표시 하기)

MSP430FR5739 EVM - ADC테스트 (전압값에 따라 게이지 그래프 표시 하기)

 


ADC10_B features include:

- Greater than 200-ksps maximum conversion rate

- Monotonic 10-bit converter with no missing codes

- REF Module 1.5V, 2V and 2.5V

- Sample-and-hold with programmable sampling periods controlled by software or timers

- Conversion initiation by software or different timers

- Software-selectable on chip reference using the REF module or external reference

- Twelve individually configurable external input channels

- Conversion channel for temperature sensor of the REF module

- Selectable conversion clock source

- Single-channel, repeat-single-channel, sequence, and repeat-sequence conversion modes

- Window comparator for low-power monitoring of input signals

- Interrupt vector register for fast decoding of six ADC interrupts (ADC10IFG0, ADC10TOVIFG,

ADC10OVIFG, ADC10LOIFG, ADC10INIFG, ADC10HIIFG)




MSP430FR5739 ADC 블록도




MSP430FR5739 ADC 초기화 함수

ADC에 사용할 포트를 설정하고 레퍼런스 및 해상도를 설정할 수 있다.

 // Sampling and conversion start

#define ADC_Start()               (ADC10CTL0 |= ADC10ENC + ADC10SC);       


void AdcInit()

{

    // Configure ADC

    P3SEL1 |= BIT0; 

    P3SEL0 |= BIT0; 

  

    ADC10CTL0 |= ADC10SHT_2 + ADC10ON;        // ADC10ON, S&H=16 ADC clks

    ADC10CTL1 |= ADC10SHP;                    // ADCCLK = MODOSC; sampling timer

    ADC10CTL2 |= ADC10RES;                    // 10-bit conversion results

    ADC10MCTL0 |= ADC10INCH_12;                // A1 ADC input select; Vref=AVCC

    ADC10IE |= ADC10IE0;                      // Enable ADC conv complete interrupt 

}


 

ADC 제어 레지스터 - 채널 설정


 

 

MSP430FR5739 ADC 테스트 동영상

 


MSP430FR5739 ADC 테스트 예제코드

unsigned int ADC_Result;


//-----------------------------------------------------------------------------

void main(void)

{

    unsigned int cnt = 0;


    SystemInit();

    

    Led1Init();

    Led1On();

//Serial Init

DebugInit(BAUD_115200);

DebugPrint("ADC Test Program.\r\n");


AdcInit();

    while(1)

    {

        __delay_cycles(5000);

        ADC_Start();        // Sampling and conversion start

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

        __no_operation();


        DebugPrint("adc=%d\r\n", ADC_Result);

    }

}

//-----------------------------------------------------------------------------





// ADC10 interrupt service routine

#pragma vector=ADC10_VECTOR

__interrupt void ADC10_ISR(void)

{

  switch(__even_in_range(ADC10IV,12))

  {

    case  0: break;                          // No interrupt

    case  2: break;                          // conversion result overflow

    case  4: break;                          // conversion time overflow

    case  6: break;                          // ADC10HI

    case  8: break;                          // ADC10LO

    case 10: break;                          // ADC10IN

    case 12: ADC_Result = ADC10MEM0;         

             __bic_SR_register_on_exit(CPUOFF);                                              

             break;                          // Clear CPUOFF bit from 0(SR)                         

    default: break; 

  }  

}



반응형