📄 fet140_sd16_grpchcontconv_isr.c
字号:
//******************************************************************************
// MSP-FET430P140 Demo - SD16, Continous Conversion on Group of Channels
//
// This example shows how to perform a continous conversion on a Group
// of channels using ISR. It performs continous conversions on channels 0,1 & 2.
// The conversion results are stored in SD16MEM0, MEM1 & MEM2. Test by
// applying a voltage to channels, then setting and running to a break point at the
// mentioned instruction. To view the conversion results, open watch
// window in C-Spy and view the contents of "Ch0results", "Ch1results", and
// "Ch2results" after running to the breakpoint.
//
// MSP430FE427
// ---------------
// | |
// | I1+ |<---- Vin 1+
// | I1- |<---- Vin 1-
// | I2+ |<---- Vin 2+
// | I2- |<---- Vin 2-
// | V1+ |<---- Vin 3+
// | V1- |<---- Vin 3-
// | |
//
//
// 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 Ch0results[Num_of_Results]; // These need to be global in
static unsigned int Ch1results[Num_of_Results]; // this example. Otherwise, the
static unsigned int Ch2results[Num_of_Results]; // compiler removes them because
// they are not used
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
SD16CCTL0 |= SD16GRP; // Enable Grouping with next higher channel
SD16CCTL1 |= SD16GRP; // Enable Grouping with next higher channel
SD16CCTL2 |= SD16IE; // Enable Interrupts
_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;
Ch0results[index] = SD16MEM0; // Move Ch0 results, IFG is cleared
Ch1results[index] = SD16MEM1; // Move Ch1 results, IFG is cleared
Ch2results[index] = SD16MEM2; // Move Ch2 results, IFG is cleared
index++; // Increment results index
if (index == 8)
{
index = 0; // SET BREAKPOINT HERE
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -