Reply by Johannes Findorf April 18, 20052005-04-18
Hi George

I haven't implemented the filter yet, but the ADC works (I hope, no
testing yet).

Here is my initADConverter function, that one is the most tricky:

void CADConverter::initADConverter()
{
    // Setup Timer_B
  P4SEL |= 0x1;
  P4DIR |= 0x1;
  TBCCR0 = XTAL_FREQ / ADC_SAMPLERATE;                // 4MHz / 8kHz
  TBCCR1 = XTAL_FREQ / (ADC_SAMPLERATE*2);            // 50% dutycycle
  TBCCTL1 = OUTMOD_3;                            // Output mode Set/Reset
  TBCTL = CNTL_1 + TBSSEL_2 + ID_0 + MC_1;
                   // 12 bit counter (kan godt blive 16 hvis det skes)
                   // SMCLK (4 MHz)
                   // DIV = 1
                   // Up-mode


  // Setup ADC
  P6SEL = 0x0F;                         // Enable A/D channel inputs
  ADC12CTL0 = ADC12ON + SHT0_3 + SHT1_3 + REFON;       // Turn on
ADC12, extend sampling time to avoid overflow of results
  ADC12CTL1 = SHS_2 + SHP + CONSEQ_3 + ADC12SSEL_2 + ADC12DIV_7;     
       // Use sampling timer, repeated sequence
  ADC12MCTL0 = INCH_7;                  // channel = A7
  ADC12MCTL1 = INCH_7;                  // channel = A7
  ADC12MCTL2 = INCH_7;                  // channel = A7
  ADC12MCTL3 = INCH_7;                  // channel = A7
  ADC12MCTL4 = INCH_7;                  // channel = A7
  ADC12MCTL5 = INCH_7;                  // channel = A7
  ADC12MCTL6 = INCH_7;                  // channel = A7
  ADC12MCTL7 = INCH_7;                  // channel = A7
  ADC12MCTL8 = INCH_7;                  // channel = A7
  ADC12MCTL9 = INCH_7;                  // channel = A7
  ADC12MCTL10 = INCH_7;                  // channel = A7
  ADC12MCTL11 = INCH_7;                  // channel = A7
  ADC12MCTL12 = INCH_7;                  // channel = A7
  ADC12MCTL13 = INCH_7;                  // channel = A7
  ADC12MCTL14 = INCH_7;                  // channel = A7
  ADC12MCTL15 = INCH_7+EOS;              // channel = A7, end seq.
  ADC12IE = 0x08000;                       // Enable ADC12IFG.15
  ADC12CTL0 |= ENC;                     // Enable conversions
  _EINT();                              // Enable interrupts
}

Hop that can help you.

.johannes


--- In msp430@msp4..., "embedded_designer_esc"
<george.martin@a...> wrote:
> 
> 
> --- In msp430@msp4..., "Johannes Findorf" <johannes@f...>
wrote:
> > 
> > 
> > Hi
> > 
> > I'm all new to the MSP430 serie (curently using MSP430F147), I
have
> > only done some small projects at Atmel before. I like to have some
> > help with a simple code that samples from the ADC (any port) at 8000
> > Hz (yes, you guest it, I'm trying to make an DTMF detector).
> > 
> > I'm using the IAR Embedded Workbench, and it have some sample
code.
> > But if I sets breakpoints in the ISR, the simulator don't halt at
the
> > breakpoint.
> > 
> > Does anyone have some small code excamples that works? Is it not
> > posible to have a breakpoint in the ISR (only if I manualy trigger the
> > interrupt from the simulator, it stops in the ISR)?
> > 
> > Best regards
> > Johannes Findorf
> 
> Hello Johannes:
> 
> I'm attempting to also do a DTMF decoder.
> I found the TI app notes and need to modify the code a bit since I
> only need a decoder not the encoder.  How are you making out? any
> words of wisdom?
> 
> THanks
> George




Beginning Microcontrollers with the MSP430

Reply by embedded_designer_esc April 16, 20052005-04-16

--- In msp430@msp4..., "Johannes Findorf" <johannes@f...> wrote:
> 
> 
> Hi
> 
> I'm all new to the MSP430 serie (curently using MSP430F147), I have
> only done some small projects at Atmel before. I like to have some
> help with a simple code that samples from the ADC (any port) at 8000
> Hz (yes, you guest it, I'm trying to make an DTMF detector).
> 
> I'm using the IAR Embedded Workbench, and it have some sample code.
> But if I sets breakpoints in the ISR, the simulator don't halt at the
> breakpoint.
> 
> Does anyone have some small code excamples that works? Is it not
> posible to have a breakpoint in the ISR (only if I manualy trigger the
> interrupt from the simulator, it stops in the ISR)?
> 
> Best regards
> Johannes Findorf

Hello Johannes:

I'm attempting to also do a DTMF decoder.
I found the TI app notes and need to modify the code a bit since I
only need a decoder not the encoder.  How are you making out? any
words of wisdom?

THanks
George







Reply by Onestone April 4, 20052005-04-04

Johannes Findorf wrote:

>Hi again
>
>I have now been reading some more, and up comes some questions about
>the ADC12CLK signal.
>
>1: In the datasheet msp430f147.pdf, it is menthioned at page 37, that
>the f(ADC12CLK) signal can have a freq from 0.45 MHz to 6.3 MHz.
>My quest: But I can set the ACLK as input to the ADC12CLK, and is has
>only 32.768 Hz, how can that workout?
>
Just because you can set ACLK as the ADC12CLK source doesn't mean
that 
it will work properly.

>
>2: Conversion time. I like to use 4kHz samplerate, this can be done by
>ACLK as input to ADC12CLK and ADC12DIV = 8 (this gives me 4096 Hz).
>
No it can't. You're confusing the ADC12CLK with sample time.
The time to 
convert each sample consists of 13 cycles of ADC12clk + how ever many 
clocks you allocate as the sample time. If you are using several 
channels of the ADC12 you must multiply this number by the number of 
channels.

>Now, section 15.6 of slau049.pdf (are there any
system in the naming
>of the TI PDF's?) I can calculate t(conversion) = 13 * ( ADC12DIV /
>fADC12CLK), this gives me t(conversion) = 13 * ( 8 / 4096 ) = 0,025390625.
>I uses all 16 registers of ADC12MEMx, and t(convsrsion)^-1 * 16 = 630
>Hz, is this a problem for me? Shall it be more than my 4096 Hz samplerate?
>(as I see it, I have no problem, as long as I can manage to empty the
>ADC12MEMx before next sample)
>
see above. You have failed to grasp the ADC12 fundamentals here. 16 
channels at 4096 khz per channel  is what you want? Then, assuming you 
allow 4 cycles for sampling, each channels requires 17 clock cycles to 
convert. The total number of clock cycles required is therefore 272. You 
require this 4096 times a second? the n the ADC12clk must be at least 
272 * 4096.

however the best way to get a periodic sample is tyo use one of the 
timer triggers available. When SHP = 1 and MSC = 1 you can use one of 3 
possible timer compare events to trigger an nADC12 conversion sequence. 
the MSC bit allows multiple repeat conversions.

To do this you need to set the timer for compare mode, set CCRnx to a 
value which gives a compare match at the required sample rate, set 
ADC12clk to AT LEAST the frequency calculated above. Then set the ADC12 
to trigger on the timer event.

once all 16 channels have converted you can transfer them to a buffer.

Al

>
>3: What would be an apropiate freq of my SHI signal? I plan on using
>the Timer_B.OUT0 signal as input. Shall it be 4 x ADC12CLK (sampling
>takes 4 x ADC12CLK)? If I was using only one ADC12MEMx register, would
>I need an SHI of (4 + 13) * ADC12CLK ?
>
>Wow, hope that you understand my questions (I accualy had some more,
>but I figured them out as I was writing this).
>
>Thanks for your help until now.
>
>Best regards
>
>Johannes Findorf
>
>PS: I have changed the samplerate from 8kHz to 4kHz, this should not
>be a problem, since the highest freq in the DTMF signal is only 1633 Hz.
>
>
>
>--- In msp430@msp4..., "Johannes Findorf" <johannes@f...>
wrote:
>  
>
>>Hi
>>
>>I'm all new to the MSP430 serie (curently using MSP430F147), I have
>>only done some small projects at Atmel before. I like to have some
>>help with a simple code that samples from the ADC (any port) at 8000
>>Hz (yes, you guest it, I'm trying to make an DTMF detector).
>>
>>I'm using the IAR Embedded Workbench, and it have some sample code.
>>But if I sets breakpoints in the ISR, the simulator don't halt at
the
>>breakpoint.
>>
>>Does anyone have some small code excamples that works? Is it not
>>posible to have a breakpoint in the ISR (only if I manualy trigger the
>>interrupt from the simulator, it stops in the ISR)?
>>
>>Best regards
>>Johannes Findorf
>>    
>>
>
>
>
>
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
>  
>


Reply by Johannes Findorf April 4, 20052005-04-04
Hi again

I have now been reading some more, and up comes some questions about
the ADC12CLK signal.

1: In the datasheet msp430f147.pdf, it is menthioned at page 37, that
the f(ADC12CLK) signal can have a freq from 0.45 MHz to 6.3 MHz.
My quest: But I can set the ACLK as input to the ADC12CLK, and is has
only 32.768 Hz, how can that workout?

2: Conversion time. I like to use 4kHz samplerate, this can be done by
ACLK as input to ADC12CLK and ADC12DIV = 8 (this gives me 4096 Hz).
Now, section 15.6 of slau049.pdf (are there any system in the naming
of the TI PDF's?) I can calculate t(conversion) = 13 * ( ADC12DIV /
fADC12CLK), this gives me t(conversion) = 13 * ( 8 / 4096 ) = 0,025390625.
I uses all 16 registers of ADC12MEMx, and t(convsrsion)^-1 * 16 = 630
Hz, is this a problem for me? Shall it be more than my 4096 Hz samplerate?
(as I see it, I have no problem, as long as I can manage to empty the
ADC12MEMx before next sample)

3: What would be an apropiate freq of my SHI signal? I plan on using
the Timer_B.OUT0 signal as input. Shall it be 4 x ADC12CLK (sampling
takes 4 x ADC12CLK)? If I was using only one ADC12MEMx register, would
I need an SHI of (4 + 13) * ADC12CLK ?

Wow, hope that you understand my questions (I accualy had some more,
but I figured them out as I was writing this).

Thanks for your help until now.

Best regards

Johannes Findorf

PS: I have changed the samplerate from 8kHz to 4kHz, this should not
be a problem, since the highest freq in the DTMF signal is only 1633 Hz.



--- In msp430@msp4..., "Johannes Findorf" <johannes@f...> wrote:
> 
> 
> Hi
> 
> I'm all new to the MSP430 serie (curently using MSP430F147), I have
> only done some small projects at Atmel before. I like to have some
> help with a simple code that samples from the ADC (any port) at 8000
> Hz (yes, you guest it, I'm trying to make an DTMF detector).
> 
> I'm using the IAR Embedded Workbench, and it have some sample code.
> But if I sets breakpoints in the ISR, the simulator don't halt at the
> breakpoint.
> 
> Does anyone have some small code excamples that works? Is it not
> posible to have a breakpoint in the ISR (only if I manualy trigger the
> interrupt from the simulator, it stops in the ISR)?
> 
> Best regards
> Johannes Findorf




Reply by Kevin Willoh March 30, 20052005-03-30
David,

I'm not sure if you've sorted your problem out yet or
not but I struggled with the ADC a number of months
ago.  Anyhow TI now (this is a relatively new
addition) has sample C code for sampling at 4096 Hz
which can easily be modified to sample at 8192
HZ....Check out the TI MSP430 section on there
website.

kevin
--- "David D. Rea" <dave@dave...> wrote:
> When using the IAR simulator, interrupts
don't
> happen on their own. You
> have to schedule them to happen at specific points,
> which you configure.
> More information is available in the EW_430 PDF file
> that is installed
> when you install Kickstart.
> 
> Sorry I can't be more specific here - I'm at work
> and I don't have my
> MSP430 tools in front of me.
> 
> Dave 
> 
> On Mon, 2005-03-28 at 12:22 +0000, Johannes Findorf
> wrote:
> > 
> > 
> > Hi
> > 
> > I'm all new to the MSP430 serie (curently using
> MSP430F147), I have
> > only done some small projects at Atmel before. I
> like to have some
> > help with a simple code that samples from the ADC
> (any port) at 8000
> > Hz (yes, you guest it, I'm trying to make an DTMF
> detector).
> > 
> > I'm using the IAR Embedded Workbench, and it have
> some sample code.
> > But if I sets breakpoints in the ISR, the
> simulator don't halt at the
> > breakpoint.
> > 
> > Does anyone have some small code excamples that
> works? Is it not
> > posible to have a breakpoint in the ISR (only if I
> manualy trigger the
> > interrupt from the simulator, it stops in the
> ISR)?
> > 
> > Best regards
> > Johannes Findorf
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > .
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> > 
> 
> 


		
__________________________________ 
 

Reply by Onestone March 30, 20052005-03-30
Johannes Findorf wrote:

>Well, thanks, that explains a lot of my
frustrations about the interrupts.
>
>But I still have some problems, probably of my lack of understanding
>the ADC. I have read the ADC chapter of the slau049.pdf, several
>times, but I still dont get the ADC to sample as I like it to do.
>
>As said before, I like the ADC to sample at about 8000 Hz.
>Can I configure the ADC to use the ADC12OSC as the SAMPCON signal (the
>SHP bit) and thereby get the samplerate?
>
No, unless you do all the calculations, and have a clock frequency that 
divides down exactly, taking into account sample period and conversion 
time (13 * adc12clk).

>Or do I have to use one of the MSP's timers?
>  
>
For accurate timing set the ADC12 to repeat sequence mode, and use one 
of the timers as the trigger.

>What exactly do the MSC bit do? If I read the part
at page 15-32 about
>the MSC, it tells me that (direct quote):
>0: The sampling timer requires a rising edge of the SHI signal to
>trigger each sample-and-conversion.
>
This is single sample mode. lets say you want to convert 8 channels, 
each would require an SHI edge to trigger the conversion if MSC = 0. If 
MSC = 1 the first SHI edge triggers the first channel conversion, and 
the remaining channels are converted automatically on completion of the 
previous conversion, ie when MSC =1 conversion completion effectively 
triggers SHI automatically.

>1: The first rising edge of the SHI signal triggers
the sampling
>timer, but further sample-and-conversion are performed automatically
>as soon as the prior conversion is completedwithout additional rising
>edges of SHI. Additional rising edges of SHI are ignored until the
>sequence has completed or the ENC bit has been toggled (depending on
>mode).
>
>To bend it in neon to myself, if MSC bit is 1, I can't control the
>freq?  (I can only get the ISR (now in hardware, not simulator) to
>work if MSC = 1)
>
Sample rate is not intended to be controlled by SHI etc. Conceivably you 
could do so by bit banging the ADC control bits as necessary. However Ti 
have provided one of the most flexible ADC peripherals I've seen in a 
small micro, so make use of the facilities. It makes absolute sense to 
use a timer to accurately time things doesn't it? Or must we always seek 
the most complicated way of doing things?

>
>Hope you dont mind helping out a newbee.
>
I never mind helping, especially when the poster, like yourself, has 
taken the time to work things out for himself, and doesn't just expect 
people to throw him their knowledge for free, and secondly when the 
poster realsies that the they need to give us as much information as 
possible, since I'm the only one here with a patented design for mind 
reading.

Cheers

Al


>Cheers Johannes Findorf
>
>
>
>
>--- In msp430@msp4..., "David D. Rea" <dave@d...> wrote:
>  
>
>>When using the IAR simulator, interrupts don't happen on their own.
You
>>have to schedule them to happen at specific points, which you configure.
>>More information is available in the EW_430 PDF file that is installed
>>when you install Kickstart.
>>
>>Sorry I can't be more specific here - I'm at work and I
don't have my
>>MSP430 tools in front of me.
>>
>>Dave 
>>
>>On Mon, 2005-03-28 at 12:22 +0000, Johannes Findorf wrote:
>>    
>>
>>>Hi
>>>
>>>I'm all new to the MSP430 serie (curently using MSP430F147), I
have
>>>only done some small projects at Atmel before. I like to have some
>>>help with a simple code that samples from the ADC (any port) at 8000
>>>Hz (yes, you guest it, I'm trying to make an DTMF detector).
>>>
>>>I'm using the IAR Embedded Workbench, and it have some sample
code.
>>>But if I sets breakpoints in the ISR, the simulator don't halt
at the
>>>breakpoint.
>>>
>>>Does anyone have some small code excamples that works? Is it not
>>>posible to have a breakpoint in the ISR (only if I manualy trigger
the
>>>interrupt from the simulator, it stops in the ISR)?
>>>
>>>Best regards
>>>Johannes Findorf
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>.
>>>
>>> 
>>>Yahoo! Groups Links
>>>
>>>
>>>
>>> 
>>>
>>>
>>>
>>>      
>>>
>
>
>
>
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
>  
>


Reply by Johannes Findorf March 30, 20052005-03-30
Well, thanks, that explains a lot of my frustrations about the interrupts.

But I still have some problems, probably of my lack of understanding
the ADC. I have read the ADC chapter of the slau049.pdf, several
times, but I still dont get the ADC to sample as I like it to do.

As said before, I like the ADC to sample at about 8000 Hz.
Can I configure the ADC to use the ADC12OSC as the SAMPCON signal (the
SHP bit) and thereby get the samplerate?
Or do I have to use one of the MSP's timers?

What exactly do the MSC bit do? If I read the part at page 15-32 about
the MSC, it tells me that (direct quote):
0: The sampling timer requires a rising edge of the SHI signal to
trigger each sample-and-conversion.
1: The first rising edge of the SHI signal triggers the sampling
timer, but further sample-and-conversion are performed automatically
as soon as the prior conversion is completedwithout additional rising
edges of SHI. Additional rising edges of SHI are ignored until the
sequence has completed or the ENC bit has been toggled (depending on
mode).

To bend it in neon to myself, if MSC bit is 1, I can't control the
freq?  (I can only get the ISR (now in hardware, not simulator) to
work if MSC = 1)

Hope you dont mind helping out a newbee.
Cheers Johannes Findorf




--- In msp430@msp4..., "David D. Rea" <dave@d...> wrote:
> When using the IAR simulator, interrupts
don't happen on their own. You
> have to schedule them to happen at specific points, which you configure.
> More information is available in the EW_430 PDF file that is installed
> when you install Kickstart.
> 
> Sorry I can't be more specific here - I'm at work and I
don't have my
> MSP430 tools in front of me.
> 
> Dave 
> 
> On Mon, 2005-03-28 at 12:22 +0000, Johannes Findorf wrote:
> > 
> > 
> > Hi
> > 
> > I'm all new to the MSP430 serie (curently using MSP430F147), I
have
> > only done some small projects at Atmel before. I like to have some
> > help with a simple code that samples from the ADC (any port) at 8000
> > Hz (yes, you guest it, I'm trying to make an DTMF detector).
> > 
> > I'm using the IAR Embedded Workbench, and it have some sample
code.
> > But if I sets breakpoints in the ISR, the simulator don't halt at
the
> > breakpoint.
> > 
> > Does anyone have some small code excamples that works? Is it not
> > posible to have a breakpoint in the ISR (only if I manualy trigger the
> > interrupt from the simulator, it stops in the ISR)?
> > 
> > Best regards
> > Johannes Findorf
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > .
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> >




Reply by David D. Rea March 29, 20052005-03-29
When using the IAR simulator, interrupts don't happen on their own.
You
have to schedule them to happen at specific points, which you configure.
More information is available in the EW_430 PDF file that is installed
when you install Kickstart.

Sorry I can't be more specific here - I'm at work and I don't
have my
MSP430 tools in front of me.

Dave 

On Mon, 2005-03-28 at 12:22 +0000, Johannes Findorf
wrote:
> 
> 
> Hi
> 
> I'm all new to the MSP430 serie (curently using MSP430F147), I have
> only done some small projects at Atmel before. I like to have some
> help with a simple code that samples from the ADC (any port) at 8000
> Hz (yes, you guest it, I'm trying to make an DTMF detector).
> 
> I'm using the IAR Embedded Workbench, and it have some sample code.
> But if I sets breakpoints in the ISR, the simulator don't halt at the
> breakpoint.
> 
> Does anyone have some small code excamples that works? Is it not
> posible to have a breakpoint in the ISR (only if I manualy trigger the
> interrupt from the simulator, it stops in the ISR)?
> 
> Best regards
> Johannes Findorf
> 
> 
> 
> 
> 
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 


Reply by Johannes Findorf March 28, 20052005-03-28

Hi

I'm all new to the MSP430 serie (curently using MSP430F147), I have
only done some small projects at Atmel before. I like to have some
help with a simple code that samples from the ADC (any port) at 8000
Hz (yes, you guest it, I'm trying to make an DTMF detector).

I'm using the IAR Embedded Workbench, and it have some sample code.
But if I sets breakpoints in the ISR, the simulator don't halt at the
breakpoint.

Does anyone have some small code excamples that works? Is it not
posible to have a breakpoint in the ISR (only if I manualy trigger the
interrupt from the simulator, it stops in the ISR)?

Best regards
Johannes Findorf