Hello Forum,
I've been trying but without success to kickstart the ADC10 on a
MSP430F1222.
I can't seem to get ADC10 to work. I simply want to measure
temperature and Vcc/2 using on-board peripherals. No external analog
signals. I want to use the Internal reference too.
I seem to be communicating with my FET okay. But setting break-points
and 'watching' ADC10 registers shows that what I want the MCU to do
isn't happenning. The ADC10 registers nor flags are being updated and
I don't get an interrupt (to confirm end of conversion).
In the background, my uC keeps a RTC, driven from a watch crystal,
ACLK, (i.e. WDT - runs in Interwal Mode. That works okay and the WDT
DOES generate Interrupts.).
I hope to use the faster, DCO for main processing, which
theoretically should result in overall low-power consumption.
About the ADC10:
I'm a bit unclear about the order of setting up the ADC10CTL0 and
ADC10CTL1 registers and bits inside them. I haven't even got round to
Data Transfer Control Registers yet...
Has anyone tried the TI 'C' sample codes, successfully? with this
part (MSP430F1222 or 1232). Did you have to make any changes to get
the code to work?
MSP430F1xxx user guide, Chapter10.ADC10, Figure 16-4 shows 'Single
Channel, Single Conversion Mode' sequence, which appears straight
forward enough, but what about initialisation prior to it. I.e. REFON
bit is apparently set automatically if INCHx
h and ENC bit must be
RESET before writing to 'CTLx registers...
Using the following sample code (fet120_adc10_temp.c) I seem to never
wake up from SLEEP (even though my GIE and ADC10IE are believed to be
set).
.
.
init_clock(); // XT1=LK and DCO
// when FET disconnected both these clock can be
seen //at the appropriate ports ACLCK and SMCLK
init_wdt(); // 1s Interval Mode
.
.
.
// Get Temperature
ADC10CTL1 = INCH_10+ADC10DIV_3; // Temp Sensor ADC10CLK/4
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;
for (delay=0; delay ; delay++);
while(1)
{
P2OUT |= SPAREIO; // TOGGLE TEST PIN
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
_BIS_SR(CPUOFF + GIE); // LPM0 with interrupts enabled
// oF = ((A10/1024)*1500mV)-923mV)*1/1.97mV = x*761/1024 - 468
temp = ADC10MEM;
IntDegF = ((temp - 630) * 761) / 1024;
// oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = x*423/1024 - 278
temp = ADC10MEM;
IntDegC = ((temp - 673) * 423) / 1024;
P2OUT &= ~SPAREIO; //
_NOP(); // SET BREAKPOINT HERE
}
.
.
.
.
}
Here is the ISR...
// ADC10 interrupt service routine
void ADC10_ISR (void) __interrupt[ADC10_VECTOR]
{
_BIC_SR_IRQ(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
Can anyone see what is wrong with this code or point me in the right
direction please.
Thanks,
PaulW.
Signal Processing Engineer Seeking a DSP Engineer to tackle complex technical challenges. Requires expertise in DSP algorithms, EW, anti-jam, and datalink vulnerability. Qualifications: Bachelor's degree, Secret Clearance, and proficiency in waveform modulation, LPD waveforms, signal detection, MATLAB, algorithm development, RF, data links, and EW systems. The position is on-site in Huntsville, AL and can support candidates at 3+ or 10+ years of experience.