📄 fet140_sd16_singchcontconv.c
字号:
//******************************************************************************
// MSP-FET430P140 Demo - SD16, Continous Conversion on Single Channel
//
// This example shows how to perform a Multiple continous SD16 conversion on a
// single channel. It uses internal reference and performs a multiple conversions
// on channel 2. Each conversion result is moved to an 8-element array called
// results[].
// Test by applying a voltage to channel 2, then running. To view the conversion
// results, open a watch window and view 'results' after running to the break
// point
//
// MSP430FE427
// ---------------
// | |
// | V1+ |<---- Vin +
// | V1- |<---- Vin -
// | |
//
//
// Harman Grewal
// Texas Instruments, Inc
// Oct, 2004
// IAR Embedded Workbench Version: 2.21B
//******************************************************************************
#include "msp430xE42x.h" // Standard Equations
#define Num_of_Results 8
static unsigned int results[Num_of_Results]; // Needs to be global in this
// example. Otherwise, the
// compiler removes it because it
// is not used for anything.
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
FLL_CTL0 |= XCAP14PF; // Set load capacitance for xtal.
for (i = 0; i < 20000; i++); // Delay - to allow watch crystal to stabilize.
SD16CTL = SD16REFON+SD16SSEL0; // Turn on SD16 Ref,SMCLK
SD16CCTL2 |= SD16IE ; // Interrupt Enable for Ch2
SD16INCTL2 |= SD16INTDLY0; // First Interrupt on 3rd Sample
_EINT(); // Enable interrupts
for ( i=0; i<0x3600; i++) // Delay for reference start-up
{
}
SD16CCTL2 |= SD16SC; // Start conversion
_BIS_SR(LPM0_bits); // Enter LPM0
}
#pragma vector=SD16_VECTOR
__interrupt void SD16ISR (void)
{
static unsigned int index = 0;
results[index] = SD16MEM2; // Move results
index++; // Increment results index
if (index == 8)
{
index = 0; // SET BREAKPOINT HERE
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -