/* ********************************************************************************************************* * intern ADC12 continiuos * ********************************************************************************************************* */ #pragma inline=forced void start_ADC( unsigned short channel, ptr_ADC cfb) { ADC12CTL0 = REFON + REF2_5V; cbf_ADC = cfb; if (P6SEL == 0) { ADC12MEM0 = 0x0; ADC12MEM1 = 0x0; ADC12MEM2 = 0x0; ADC12MEM3 = 0x0; } P6SEL |= 0x0F; ADC12CTL0 |= ADC12ON + SHT0_2 + MSC; // Turn on ADC12, set sampling time ADC12CTL1 |= SHP + CONSEQ_2; ADC12IE = channel; //enable interrupt ADC12CTL1 |= CSTARTADD_0; switch(channel) { case(BIT0): ADC12MCTL0 |= INCH_0 + SREF_1 + EOS; break; case(BIT1): ADC12MCTL1 |= INCH_1 + SREF_1 + EOS; break; case(BIT2): ADC12MCTL2 |= INCH_2 + SREF_1 + EOS; break; case(BIT3): ADC12MCTL3 |= INCH_3 + SREF_1 + EOS; break; } ADC12CTL0 |= ENC; ADC12CTL0 |= ADC12SC; } ;******************************************************************************************************** ; ADC12_ISR ;******************************************************************************************************** ADC12ISR ; ADC12_ISR PUSHALL ; push all registers bic.w #BIT0, &ADC12IFG ; clear ADC12IFG interrupt flag BIT0 - BIT3 cmp.b #0, &OSIntNesting ; if (OSIntNesting == 0) jne ADC12ISR_1 mov.w &OSTCBCur, R13 ; save task stack mov.w SP, 0(R13) mov.w &OSISRStkPtr, SP ; load interrupt stack ADC12ISR_1 inc.b &OSIntNesting ; increase OSIntNesting bis.w #BIT0 , ADC12IE ; enable ADC12 interrupt BIT0 - BIT3 EINT ; enable general interrupt to allow for interrupt nesting call #ADC12IntHandler ; call ADC interrupt handler DINT ; IMPORTANT: disable general interrupt BEFORE calling OSIntExit() call #OSIntExit ; call ticks routine cmp.b #0, &OSIntNesting ; if (OSIntNesting == 0) jne ADC12ISR_2 mov.w &OSTCBHighRdy, R13 ; restore task stack SP mov.w @R13, SP ADC12ISR_2 POPALL ; pop all registers reti ; return from interrupt /* ********************************************************************************************************* * ADC12IntHandler * ********************************************************************************************************* */ void ADC12IntHandler () { cbf_ADC(); // call the testf2_ADC12 function } /* ********************************************************************************************************* * testfunction for ADC12 ********************************************************************************************************* */ void testf2_ADC12(void) { static unsigned int index = 0; ADC_result[index] = ADC12MEM0; // Move results index = (index+1)%4; }