jsolarski 94 Posted July 30, 2011 Author Share Posted July 30, 2011 its finally working like its supposed to now!!thanks for all the help so far Test code /*****************************************************************************/ //Author- Justin Solarski //Copyright 2011 justinstech.org #include /*****************************************************************************/ volatile unsigned int results = 0; /*****************************************************************************/ /*****************************************************************************/ void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT //basic clock settings DCOCTL = CALDCO_1MHZ; BCSCTL1 = CALBC1_1MHZ; BCSCTL2 |= DIVS_3; //divide smclk/8 125000Hz //GPIO setup P2DIR |= BIT7; P1DIR |= BIT6; //sd16 settings SD16CTL = SD16REFON + SD16SSEL_1; // 1.2V ref, SMCLK //SD16CTL |= SD16XDIV_3; // clk/48 2604hz SD16INCTL0 = SD16INCH_0; // A1+/- P1.2 SD16CCTL0 = SD16IE; // 256OSR, bipolar offset, interrupt enable SD16AE = SD16AE0; // P1.1 A1+, A1- = VSS SD16CCTL0 |= SD16SC; // Set bit to start conversion _BIS_SR(LPM0_bits + GIE); } /*****************************************************************************/ // SD16 ISR #define THRSHMAX 0xc000 // not used yet #define THRSHMIN 0x4000 // not used yet __attribute__((interrupt(SD16_VECTOR))) void Sd16_Isr(void){ // 0000 - FFFF -- 8000 = halfway point or 1.2V //P1DIR ^= BIT6; results = SD16MEM0; if (results < 0x4000) { //results is less then 0x4000 P1OUT |= BIT6; } else if ( results > 0xc000) { // results greater then 0x9000 P1OUT |= BIT6; } else { P1OUT = 0; } } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.