Hi,
I would like to know what happen to output signal if I'm not going to output it to port pins, meaning no PxSEL?
Is this safe?
Here is the case.
I have some LEDs connected to port pins which don't have a hardware pwm capability. And other port pins which has hardware pwm are already occupied by something else and I cannot switch their port, they are fixed already. I'm using MSP430F5505.
I would like to output a pwm signal to those LEDs (P1.0, P5.0 & P5.5) and I'm using TimerA compare mode. Instead of using PxSEL to output hardware pwm to output signal to port pins (applicable only to P1.7/TA1.0 and P2.0/TA1.1) which is impossible in my case, I'm doing a software pwm using TimerA compare mode, see the code below.
void TimerA1_Init() { //TA1CCTL0 = CCIE; /* CCR0 Interrupt Disable */ TA1CCTL1 = OUTMOD_1 + CCIE; TA1CCTL2 = OUTMOD_1 + CCIE; //TA1CCTL3 = OUTMOD_4 + CCIE; TA1CCR0 = 50000; /* Timer counter compare to this value */ TA1CCR1 = 500; TA1CCR2 = 300; TA1CTL = TASSEL_2 + MC_2 + TACLR + TAIE; /* Select SMCLK, CONT Mode, Reset counter*/ } #pragma vector=TIMER1_A1_VECTOR __interrupt void Timer1_A1_ISR(void) { switch(__even_in_range(TA1IV,14)) { case 0: break; case 2: P5OUT ^= 0x01; // Add Offset to CCR1 break; case 4: P5OUT ^= 0x05; // Add Offset to CCR2 break; case 6: break; // CCR3 not used case 8: break; // CCR4 not used case 10: break; // CCR5 not used case 12: break; // Reserved not used case 14: P1OUT ^= 0x01; // overflow break; default: break; } }
Thank you,
Gee