This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Issue of using same channel of timer TM_TA0.x

Other Parts Discussed in Thread: MSP430F67641

Hello All,

I am working on msp430f67641 mcu. 

I am confuse about using the PWM in UP_mode and Capture in Continue_Mode of same channel.

my setup:- 

PWM :-  P3.3/PM_TA0.2

Capture Mode :- P1.1/PM_TA0.1/VeREF+/A1

i  using PWM for the LED brightness control and Capture mode for the audio detection. When running the separate code it is working fine but when i merge it is not working.

My code:- 

void mic_init(void)
{
     TA0CTL = TASSEL_2 + MC_2 + ID_3; // Timer A 0 with SMCLK @ 8MHz, count UP
    TA0CCTL1 |= CM_1 + CCIS_0 + SCS + CAP + CCIE; // Raising Edge + CCI0A + Sync + Capture Mode + Interrupt enable

     // MIC pin intialize
    P1DIR &= ~(BIT1); // make the pin as input
    P1SEL |= (BIT1); //set this bit as Input Capture (TA0.CCI0A)

    _BIS_SR(GIE); // Global interrupts enabled
    prev_count = TA0R; // save the previous count
}

void rgb_led_pwm(void)
{
     // Configure RGB Led Pins As Output and PWM control
   P3DIR |= BIT3;
   P3SEL |= BIT3;

  TA0CCR0 = 5000-1; // PWM Per`iod
  TA0CCTL2 = OUTMOD_7; // CCR2 reset/set
  TA0CCR2 = 0; // CCR2 PWM duty cycle
  TA0CTL = TASSEL_2 | MC_1 | TACLR; // ACLK, up mode, clear TAR
}

I am stuck here..give me the solution...

  • Obviously pwm and capture can't work simultaneously in such case because CCR0 defines PWM period but on the other hand you want it to be capture register for audio detection.

    Chip you use have loads of timers. Why don't you just use two separate timers?

**Attention** This is a public forum