Tool/software: Code Composer Studio
Hello,
First thanks for viewing this and helping me. I will try and keep this quick and concise. I am using timerA0_A3 and setting up with the following code. I have confirmed that these settings took in the register tab provided in CCS. Basically my problem is that when I set a TA0CCR0 value I am not viewing that this interrupt is being timed properly when I set a pin high and then low. on an O-scope.
TA0CTL = (TASSEL_1 | ID_3 | MC_1 | TACLR ); // ACLK, DIV BY 8 , Up mode: Timer counts up to TACCR0., clear at start
TA0CCTL0 = CCIE; // capture/compare interrupt enabled TimerA0
I have a case statement for setting the TA0CCR0. the time in seconds can be calculated by ..... time_in_seconds = (8 * TA0CCR0) / 32KHz due to the fact that I set TASSEL_1 | ID_3
case 12: // 32KHz clk
{
switch(letter)
{
case '1':
{
TA0CCR0 = 2; // 488us
time_in_seconds = 0.00048828125; // time in ms = (8 * TA0CCR0) / 32KHz
G_cmdfsm =1;
break;
}
case '2':
{
TA0CCR0 = 4; //1ms
time_in_seconds = 0.009765625; OBSERVED A PERIOD OF 9.76MS
G_cmdfsm = 1;
break;
}
case '3':
{
TA0CCR0 = 41; //10 ms
time_in_seconds = 0.010009765625;
G_cmdfsm = 1;
break;
}
case '4':
{
TA0CCR0 = 410; //100 ms OBSERVED A PERIOD OF 802.5MS
time_in_seconds = 0.10009765625;
G_cmdfsm = 1;
break;
}
case '5':
{
TA0CCR0 = 2048; //500ms OBSERVED A PERIOD OF 4 SECONDS
time_in_seconds = 0.5;
G_cmdfsm = 1;
break;
}
case '6':
{
TA0CCR0 = 4096; //1 seccond
time_in_seconds = 1; // 1 second = 1000 ms :)
G_cmdfsm = 1;
break;
}
case '7':
{
TA0CCR0 = 8192; //2 seccond
time_in_seconds = 2; // 1 second = 1000 ms :)
G_cmdfsm = 1;
break;
}
}
break;
}
Finally the interrupt is doing the following.....
#pragma vector = TIMER0_A0_VECTOR //600 us
__interrupt void Timer_A_CCR0_ISR(void)
{
P2OUT |= BIT4; //pin 5 high
/*
//CPR=1250;
cntr_register(IR_LOAD, IR_OTR, 0, NULL);
initial_counter_value = cntr_register(IR_RD, IR_OTR, COUNTER_REG_SIZE, NULL); // read the counter to get a baseline
calculated_rpm = (number_of_counts_per_sample_peiod*(60/time_in_seconds/(5000)));
//calculated_rpm = (number_of_counts_per_sample_peiod*(60/(time_in_ms)/(1000)))/(4*CPR);
trunc (calculated_rpm);
number_of_counts_per_sample_peiod = initial_counter_value - end_of_timer_counter_value;
//printf(" %d",number_of_counts_per_sample_peiod);
printf("%d ", calculated_rpm);
cntr_register(IR_LOAD, IR_OTR, 0, NULL);
end_of_timer_counter_value = cntr_register(IR_RD, IR_OTR, COUNTER_REG_SIZE, NULL);
*/
P2OUT &= ~BIT4; // pin 5 low
}// end timer
However I am not getting the proper period when i set the pins high then low (even when I comment out all the code . The timers I observed can be found in the case statement. As can be seen he values are very far off from what i would expect. I have looked at how long that code is taking to calculate and it takes 600us to execute the calculations and the print statement in the timer. I hope that made sense.... Thanks for any help you can give me.