Hi,
I'm having problems with multiple-PWM signals on my G2553, to be more specific, only with timer A1 and TA1CCR2.
The entire thing is based on slaa513 and i don't see the point where i'm making a mistake.
I'm looking at it for a few days now and i don't get it to work by trying different things in the code.
The behaviour that i see is that i get interrupts on Timer A1, also i get them for TA1CCR2 (TA1IV -> case 2), but it does not detect if the pin is high (TA1CCTL2 & CCI ).
When looking at the pin with a scope, i'll see that the pin is high and low, 60us high and 60us low (so a duty-cycle of 50%).
So it looks like that (TA1CCTL2 & CCI) is always false, so the code "TA1CCR2 += 160;" is never executed (also placed breakpoints here, never executed).
Fot the other counters TA1CCR0 and TA1CCR1 it is working as expected, the code is very simular.
Below the simplified code i'm using, which still contains the weird behavior.
Also disabled the other counters and the problem is persitent.
Any help is appeciated.
#include <msp430.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
if (CALBC1_8MHZ ==0xFF || CALDCO_8MHZ == 0xFF) // If calibration data is erased
{
while(1); // TRAP
}
BCSCTL1 = CALBC1_8MHZ; // Set range
DCOCTL = CALDCO_8MHZ; // Set DCO step + modulation
BCSCTL2 |= SELM_0 + DIVM_0; // MCLK = DCOCLK
BCSCTL3 |= LFXT1S_0 + XCAP_3 + DIVA_0; // LFXT1 = 32768 crystal
__delay_cycles(55000); // let crystal stabilize
IFG1 &= ~OFIFG; // Clear OSCFault flag
if (IFG1 & OFIFG) // If OSCFault is still on
{
while(1); // TRAP
}
P1SEL = 0x00; // no specific register selected, all pins are GPIO-pins (digital)
P1SEL2 = 0x00; // default I/O function is selected
P2SEL2 = 0x00; // default I/O function is selected
P1DIR = 0x00; // default all output
P1OUT = 0x00; // default all low
P2DIR = 0x00; // default all output
P2OUT = 0x00; // default all low
P1REN = 0x00; // default no pullup/pulldown resistors
P2REN = 0x00; // default no pullup/pulldown resistor
// TA1CCTL0 = OUTMOD_4 + CCIE; /* Timer1_A3 Capture/Compare Control 0 */
// TA1CCTL1 = OUTMOD_4 + CCIE; /* Timer1_A3 Capture/Compare Control 1 */
TA1CCTL2 = OUTMOD_4 + CCIE; /* Timer1_A3 Capture/Compare Control 2 */
TA1CTL = TASSEL_2 + MC_2 + ID_3 + TAIE; /* Timer1_A3 Control, SMCLK@8MHZ divide by 8 => 1MHz */
P2DIR |= (BIT0|BIT1|BIT5); // BIT0 on P2.0; BIT1 on P2.1; BIT5 on P2.5
P2SEL |= (BIT0|BIT1|BIT5); // primary register selected
P2SEL2 &= ~(BIT0|BIT1|BIT5); // make sure they are 0
__enable_interrupt();
while (1)
{
}
}
//#pragma vector=TIMER1_A0_VECTOR
//__interrupt void Timer_A0 (void)
//{
// // P2.0
// if(TA1CCTL0 & CCI) //If output currently high
// {
// TA1CCR0 += 400; // % high
// }
// else
// {
// TA1CCR0 += 100; // low for rest of the period
// }
//}
#pragma vector=TIMER1_A1_VECTOR
__interrupt void Timer_A1(void)
{
switch( TA1IV )
{
// //P2.1
// case 2:
// if (TA1CCTL1 & CCI) // If output currently high
// {
// TA1CCR1 +=10;
// }
// else
// {
// TA1CCR1 +=50;
// }
// break;
//P2.5
case 4:
if ( TA1CCTL2 & CCI ) // If output currently high
{
//-->> CODE NEVER GETS HERE?
TA1CCR2 += 160;
}
else
{
TA1CCR2 += 60;
}
break;
default: break;
}
}