Hi all, I have a great (and working) example PWM code for pin 27 (P22_TA11), but I'm having problem doing the apparently simple porting to pin 26 (P21_TA10). Could someone help? Should I use TA0? Or is it still TA1, but use CCR0, CTL0? I'm all confused about all the 0 and 1 endings for these registers. OR only need to change the port pin definition to BIT1? What am I missing? This is the code that works: #define MOTOR_DEFAULT_DUTYCYCLE ( 13 ) // default duty cycle #define MOTOR_PWM_PERIOD ( 512 ) // default PWM period #define MOTOR_PWM_SEL P2SEL #define MOTOR_PWM_DIR P2DIR #define MOTOR_PWM_PIN BIT2 void motorInitInterface( void ) { // Port configuration MOTOR_PWM_SEL |= MOTOR_PWM_PIN; // Motor PWM function MOTOR_PWM_DIR |= MOTOR_PWM_PIN; // Output // Setup Timer A, PWM TA1CTL = TASSEL_1 + MC_3; // SMCLK, up down mode */ TA1CCR0 = MOTOR_PWM_PERIOD; // PWM Period motorSetDutyCycle( MOTOR_DEFAULT_DUTYCYCLE ); //Set PWM Duty Cycle TA1CCTL1 = OUTMOD_2; // TACCR1 set/reset mode } void motorSetDutyCycle( U08 DutyCycle ) { TA1CCR1 = ( ( U32 )DutyCycle * ( U32 )MOTOR_PWM_PERIOD ) / 100 ; // Set PWM Duty Cycle } Thanks !!!!!! Cheers, Gil
↧