
iVenky
-
Content Count
15 -
Joined
-
Last visited
Reputation Activity
-
iVenky reacted to Sir Ferdek in adc sampling time problem
If you want to connect ADC12OSC to oscilloscope you need to:
1) set ADC12CLK to use ADC12OSC (this is default, so no need to do that)
2) using P2SELx and P2SEL2x change function of P2.7 to give you the output of ADC12CLK
For instance, when using launchpad, I would have to:
P1DIR |= BIT3; P1SEL |= BIT3; P1SEL2 &= ~BIT3;
Be warned:
"The ADC10OSC, generated internally, is in the 5-MHz range, but varies with individual devices, supply
voltage, and temperature. See the device-specific data sheet for the ADC10OSC specification."
-
iVenky reacted to Sir Ferdek in adc sampling time problem
Hello.
First of all, set GIE bit only once, before the 'while(1)' loop:
__bis_SR_register(GIE); while (1) { ADC12CTL0 |= ADC12SC; // Start sampling/conversion __bis_SR_register(LPM0_bits); // LPM0, ADC12_ISR will force exit }
Next, rewrite your interrupt procedure and learn some GNU C tricks (dunno if it works with IAR/CCS, but if they call them C compilers, it should :think: ). Honestly, this is the part of your code that makes sampling so freaking slow. You're simply killing CPU with unneeded calculations and memory operations. Try this (not tested ):
#pragma vector = ADC12_VECTOR __interrupt void ADC12_ISR(void) //oh yeah, another IAR/CCS user { // Toggled this to check the sampling rate P5OUT^=0x02; P4OUT = ADC12MEM0; P3OUT = ADC12MEM0 >> 4; //or ((ADC12MEM0 >> 4) && 0xF0) if you like. __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 }
Nice, huh?
If it doesn't help, then set DCO to something like 8~16MHz and let the smile on your face appear.
-
iVenky reacted to Sir Ferdek in adc sampling time problem
In your case (single channel single-conversion mode) the answer is: no, not automaticaly. You start ADC by setting ADC12SC bit, which is automagicaly cleared after the conversion. And you set it in the while(1) loop, after waking up from LPM0
Try this:
if (CALBC1_16MHZ ==0xFF || CALDCO_16MHZ == 0xFF) while(1); // If calibration data is erased // trap CPU BCSCTL1 = CALBC1_16MHZ; // Set range DCOCTL = CALDCO_16MHZ; // Set DCO step + modulation