EmbeddedRelated.com
Forums

DTMF in MSP430

Started by gbyleveldt01 May 31, 2004
Hi all,

Matthias was nice enough to point me to the App notes for generating 
DTMF tones on MSP430. I've managed to get it working, but I'm not 
100% happy with the result. I'm using an 'F149. What I've done is
to 
toggle an output pin within the CCR0 interrupt of TimerA. This works 
100%, but when I toggle another pin within CCRx interrupt of TimerA, 
I seem to get 'jitter' on both outputs, although it is VERY slight. 
It seems to be working, the device receiveing the DTMF signals 
responds properly, but I'm concerned that this 'jitter' caused by
the 
interrupt latency might cause problems with this system deployed out 
in the field (you know Murphy!!). The correct way would be to use the 
TimerA outputs, as these are controlled by hardware. This is know the 
problem. Please refer to code:


interrupt [0xa] void Timer_A1(void)
{
  if (TAIV == 2)
  {
    TACCR1 = TACCR1 + 188;      //For about 1633Hertz.
  }
}


void main(void)
{  
  WDTCTL = 0x5a80;
  BCSCTL1 &= 0x7f;
  if (IFG1 & 2) IFG1 &= ~2;
  BCSCTL2 = 0x88;
  //Setting timer settings and outputs
  P1SEL = 0xff;
  P1DIR = 0xff;  
  TACTL = TASSEL_2 + TAIE + TACLR + MC_2;  //SMCLK, continous up
  TACCTL0 = OUTMOD_4 + CCIE;               //Toggle, enable interrupt
  TACCTL1 = OUTMOD_4 + CCIE;
  //*********************************
  FCTL2 = 0xa54f;
  _BIS_SR(GIE);
}

What I get is 37Hz pulses with about 6khz bursts, which is obviously 
incorrect. Am I doing something stupid? (probably!!!)

Btw, I'm using the IAR compiler!

Thanks guys!!!

Gert


Beginning Microcontrollers with the MSP430

On Mon, May 31, 2004 at 11:45:46AM -0000, gbyleveldt01 wrote:

> interrupt [0xa] void Timer_A1(void)
> {
>   if (TAIV == 2)
>   {
>     TACCR1 = TACCR1 + 188;      //For about 1633Hertz.
>   }
> }
> 
> 
> void main(void)
> {  
>   WDTCTL = 0x5a80;
>   BCSCTL1 &= 0x7f;
>   if (IFG1 & 2) IFG1 &= ~2;
>   BCSCTL2 = 0x88;
>   //Setting timer settings and outputs
>   P1SEL = 0xff;
>   P1DIR = 0xff;  
>   TACTL = TASSEL_2 + TAIE + TACLR + MC_2;  //SMCLK, continous up
>   TACCTL0 = OUTMOD_4 + CCIE;               //Toggle, enable interrupt
>   TACCTL1 = OUTMOD_4 + CCIE;
>   //*********************************
>   FCTL2 = 0xa54f;
>   _BIS_SR(GIE);
> }
> 
> What I get is 37Hz pulses with about 6khz bursts, which is obviously 
> incorrect. 

And you want 6kHz? It seems that sometimes TACCR1 is not updated 
correctly or fast enough and runs the full 65536. Probably another
interrupt blocks your timer a int-routine.

        Matthias

Matthias,

It would appear I owe you two cases of beers!!! I did my original 
calculations on the interrupt driven arrangement as stated before. It 
would appear as if the new arrangement of using the TimerA outputs 
directly runs faster?! Anyway, I increased the number being added to 
the TACCR1 register and it works properly. It also works in 
conjunction with the TACCR2 output, so Ive got two PERFECT square 
waves at different frequencies.

Thanks a lot Matthias.

Gert

--- In msp430@msp4..., Matthias Weingart <msp430@p...> wrote:
> On Mon, May 31, 2004 at 11:45:46AM -0000,
gbyleveldt01 wrote:
> 
> > interrupt [0xa] void Timer_A1(void)
> > {
> >   if (TAIV == 2)
> >   {
> >     TACCR1 = TACCR1 + 188;      //For about 1633Hertz.
> >   }
> > }
> > 
> > 
> > void main(void)
> > {  
> >   WDTCTL = 0x5a80;
> >   BCSCTL1 &= 0x7f;
> >   if (IFG1 & 2) IFG1 &= ~2;
> >   BCSCTL2 = 0x88;
> >   //Setting timer settings and outputs
> >   P1SEL = 0xff;
> >   P1DIR = 0xff;  
> >   TACTL = TASSEL_2 + TAIE + TACLR + MC_2;  //SMCLK, continous up
> >   TACCTL0 = OUTMOD_4 + CCIE;               //Toggle, enable 
interrupt
> >   TACCTL1 = OUTMOD_4 + CCIE;
> >   //*********************************
> >   FCTL2 = 0xa54f;
> >   _BIS_SR(GIE);
> > }
> > 
> > What I get is 37Hz pulses with about 6khz bursts, which is 
obviously 
> > incorrect. 
> 
> And you want 6kHz? It seems that sometimes TACCR1 is not updated 
> correctly or fast enough and runs the full 65536. Probably another
> interrupt blocks your timer a int-routine.
> 
>         Matthias