hello, the code given bellow is to generate 250Kz with 50% duty cycle at port P1.2 and also to convert the analogue input at P1.3. 250Kz frequency is obtained but the adc output is zero for analogue input 2.5V. can u please help me to identify the mistake i have done. // Global variables #include unsigned int ADC_value=0; // Function prototypes void ConfigureAdc(void); void main(void) { { BCSCTL1 = CALBC1_16MHZ; // Set range DCOCTL = CALDCO_16MHZ; P1DIR |= BIT2; // P1.2 to output P1SEL |= BIT2; P1SEL |= BIT3; /*** Timer0_A Set-Up ***/ TA0CCR0 = 64-1 ; // setting the frequency to 250KHz TA0CCTL1 = OUTMOD_7; TA0CCR1 = 32; //50% dutycycle TA0CTL = TASSEL_2 + MC_1; // SMCLK, up mode _BIS_SR(LPM0_bits); // Enter LPM0 } ConfigureAdc(); // ADC set-up function call __enable_interrupt(); // Enable interrupts. while(1) { __delay_cycles(1000); // Wait for ADC Ref to settle ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // Low Power Mode 0 with interrupts enabled ADC_value = ADC10MEM; // Assigns the value held in ADC10MEM to the integer called ADC_value } } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR (void) { __bic_SR_register_on_exit(CPUOFF); // Return to active mode } } // Function containing ADC set-up void ConfigureAdc(void) { ADC10CTL1 = INCH_3 + ADC10DIV_3 ; // Channel 3, ADC10CLK/3 ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; // Vcc & Vss as reference, Sample and hold for 64 Clock cycles, ADC on, ADC interrupt enable ADC10AE0 |= BIT3; // ADC input enable P1.3 } thanks and regards, anjali
↧