Hi ,
I have an application involving ADC12 of msp430f5324 device where signal to be measured of 50 Hz to 200 Hz
Frequency and I have 8 such signals.
Q1 . I want to be sure whether the way I am configuring & using the ADC is correct ? I have not used internal
ADC12OSC assuming that it requires a calibration routine and can vary from 4.2 to 5.4 MHz.
In a 'sequence of channels" mode shall i first reset ADC12SC bit and then read the ADC12MEMx ?
My objective is :
a) Start the sample & conversion from timer interrupt routine.
b) By the time next timer interrupt( 156.25 usec later) comes, adc should have sampled & converted and store the result of all 8 channel in adc buffer.
void adcInit(){
REFCTL0 &= ~REFMSTR;
__delay_cycles(5);
ADC12CTL0 &= ~ADC12ENC;
ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_4+ADC12SHT1_4+ADC12REF2_5V+ADC12REFON;
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_1+ADC12SSEL_3+ADC12DIV_6; // seq of ch + adcclk : SMCLK/7
ADC12CTL2 = ADC12RES_2; // Resolution : 12 Bit
ADC12MCTL0 = ADC12SREF_1+ADC12INCH_0; // ref+= vref, channel = A0
ADC12MCTL1 = ADC12SREF_1+ADC12INCH_1; // ref+= vref, channel = A1
ADC12MCTL2 = ADC12SREF_1+ADC12INCH_2; // ref+= vref, channel = A2
ADC12MCTL3 = ADC12SREF_1+ADC12INCH_3; // ref+= vref, channel = A3
ADC12MCTL4 = ADC12SREF_1+ADC12INCH_4; // ref+= vref, channel = A4
ADC12MCTL5 = ADC12SREF_1+ADC12INCH_5; // ref+= vref, channel = A5
ADC12MCTL6 = ADC12SREF_1+ADC12INCH_6; // ref+= vref, channel = A6
ADC12MCTL7 = ADC12SREF_1+ADC12INCH_7; // ref+= vref, channel = A7
ADC12MCTL8 = ADC12SREF_1+ADC12INCH_8+ADC12EOS; // ref += vref, channel = A8,end of sequence
ADC12CTL0 |= ADC12ENC; // Enable conversions
ADC12CTL0 |= ADC12SC; // Start convn - software trigger
__delay_cycles(75); // stabilize internal vref
}
void Timer interrupt routine(){ // will call it @ 156.25 usec or 6400 Hz
// Read all samples from ADC12MEMx
// accumulate n sample in a buffer ;
ADC12CTL0 &= ~( ADC12ENC + ADC12SC ) ;
ADC12CTL0 |= ( ADC12ENC + ADC12SC ) ;
void main(){
--------
adcInit();
while(1){
// process the accumulated samples.
Q2 . pls refer the following details from data sheet .
Let’s say 25 MHz crystal oscillator used and MCLK = 25 MHz and ADC12CLK source is MCLK.
Ref used is internal vref . so SREF1 = 1 & REFOUT = 0 ,ADC12SR = 0
And does it mean to say in the above scenario fADC12CLK would be 0.45 to 2.7 MHz
Correct me if I have mistaken!
Thanks n regards
Ars
ArsI have not used internal ADC12OSC assuming that it requires a calibration routine and can vary from 4.2 to 5.4 MHz.
Ars In a 'sequence of channels" mode shall i first reset ADC12SC bit and then read the ADC12MEMx ?
ArsStart the sample & conversion from timer interrupt routine.
ArsBy the time next timer interrupt( 156.25 usec later) comes, adc should have sampled & converted and store the result of all 8 channel in adc buffer.
Ars Let’s say 25 MHz crystal oscillator used and MCLK = 25 MHz and ADC12CLK source is MCLK.
Ars And does it mean to say in the above scenario fADC12CLK would be 0.45 to 2.7 MHz
In this case you'llneed to set REFOUT=1 and provide the required external capacitors. Same for using ADC12OSC. I'm a bit surprised that using ADC12OSC will operate the ADC ina way that it will leave the specified performance range when usign the internal reference. Thsi seems to be a limitation of thsi specific MSP. The 5438A doesn't have this limitation in the datasheet. The 5438 errata sheet, however, lists the 2.7MHz limitation with REFOUT=0.
Well, you can still use REFOUT=0 and ADC12DIV_1 while staying with ADC12OSC. Just keep in mind that you have eight signals, each conversion takes 13+n clock ticks (n depends on ADC12SHTx setting) and the total needs to fit into your timing interval.
Ars void Timer interrupt routine(){ // will call it @ 156.25 usec or 6400 Hz
_____________________________________Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.
Hi Jens !!
Thanks .
Jens-Michael Grossdidn't you say 200Hz? The sequence only needs to be started once every 1/200s for all channels being sampled with 200Hz. Where did you get the 6400Hz from?
Yes the frequency of the signal to be measured is between 50 Hz to 200 Hz . And My code reads the ADC12 buffer at a rate of 6400Hz ( 156.25 uSec). So the distance between two reading of 8 channel is 156.25 usec at a sys clock of 25 MHz.
Actually I have to run a timer interrupt ( 156.25 usec) for other tasks. So I thought to use it for ADC too. Hence explicitly started the sample & conversion of adc signal ( by setting ADC12SC bit) from this routine.
using ADC in a sequence of channel mode
Hence each adc channel will take 64 + 13 ADC12Clk cycles. So 8 channel will take 8 x ( 64 + 13 )adc12clk time which is well within my timer interrupt time.
As per my understanding ADC will finish one sequence of sample & conversion and sit idle after 8 x ( 64 + 13 )adc12clk time and will wait for a rising edge on ADC12SC bit for next sequence and that I am doing from the timer interrupt routine.
My doubt is that If I do so, still adc12 sampling period will be as per ADC12SHT0_4, ADC12SHT1_4 bits?
What is ADC12MSC bit does? Does it samples multiple time ? then how many samples?
In general how much sample time will be required for <1LSB error?
regards,
ArsIf I do so, still adc12 sampling period will be as per ADC12SHT0_4, ADC12SHT1_4 bits
ArsWhat is ADC12MSC bit does? Does it samples multiple time ? then how many samples?
ArsIn general how much sample time will be required for <1LSB error?