Jump to content
43oh

Recommended Posts



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; }





}

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...