Can a Timer Capture Compare be skipped if needed?
I'm using a Timer (TIM8) in a capture compare application for measuring timing between signals. In some cases I don't need the value so I have been skipping the read of the CCRx register. I'm using a HAL command as the code below shows:
The HAL_TIM_ReadCapturedValue() simply reads the CCRx register.
I'm counting on the Timer to continue running and the next IRQ will capture a timer value that would be the same whether or not the previous IRQ occurred. Is this a valid assumption?
I realize the overflow flag will likely be set when I skip a read of the CCRx register but does this have any unforeseen consequences?
if( htim->Instance == TIM8)
{
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1)
{
// toggle ref for viewing in ST GUI
g_nFrefSignal = !g_nFrefSignal ;
// received REF edge which is 'PU', update state machine,
switch (p_mPFD->State)
{
case COAST:
p_mPFD->State = ACCEL;
buffer1[0] = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1) ;
(p_mPFD->pu_cnt)++;
break;
case DECEL:
p_mPFD->State = COAST;
buffer1[0] = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1) ;
(p_mPFD->pu_cnt)++;
break;
case ACCEL:
p_mPFD->State = ACCEL;
p_mPFD->pu_cnt = 0;
break;
default:
p_mPFD->State = COAST; // should never get here
}
// capture Fref period for FRF command
TIM8_Current++;
}Thanks,
Brian
