Hello;
Is it possible to change the PW based on the user input. Keeping the period constant and varying the duty cycle. I am using Timer B. The code is as shown below and I see the same output. I tried clearing the registers through TBCLR and later set the clock, TBBCR0 and count direction with no success. During the user input, I can see the LED resetting to the new values for a short duration but it returns back to the original cycle.
I have set the clock for 1MHZ and Timer as follows:
BCSCTL1 = CALBC1_8MHZ; // Set DCO = 8MHz for MCLK
DCOCTL = CALDCO_8MHZ;
BCSCTL2 |= DIVS_3;
TBCCTL0 = CCIE;
TBCCTL0 |= OUTMOD_7;//
TBCTL |= CNTL_0; //16 bit counter
TBCCR0 = 65000;
TBCTL |= TBSSEL_2 + MC_2 + ID_3;
In the Interrupt, based on the user input, I set the TBCCR1 and then toggle the output LED and the output
if( value == '0') { //shut the light
TBCCR1 = 50000;
} else if( value == '1') { //PW duration is longer
TBCCR1 = 500;
}
P4OUT ^= BIT5;
P1OUT ^= 0x01;
Dave