2021-06-16 02:15 PM
I'm trying to count the number transition during the time another process is taking place. Don't need frequency, just the counts.
So I've enabled TIM8CH3 for capture-compare, and have verified that CCR3 does change when there are transitions on the input... however, it always accumulates, and I can'tclear by writing 0 to CCR3... nor by re-initializing the timer itself.
htim8->Instance.CC3 = 0;
MX_TIM8_Init();
HAL_TIM_Base_Stop(&htim8);
HAL_TIM_Base_Start(&htim8);
HAL_TIM_IC_Start(&htim8, TIM_CHANNEL_3);
How can the capture-compare register contents be cleared?
2021-06-28 03:43 PM
I don't know what do you mean by "ETR1/CH1", there is no such trigger source. I don't speak the Cube gobbledygook, I follow the terminology in the RM. In TIMx_SMCR.TS, select either TI1F_ED, if you want to trigger on both edges; or simply TI1FP1. You then want to select External Clock Mode 1 in TIMx_SMCR.SMS.
> TIM8_CH3 as Input Capture Direct Mode ?
No, at TIM level forget about CH3, the only moment where in TIM we talk about CH3 is the XOR, i.e. you set TIMx_CR2.TI1S and you're done with CH3. Input to TIM is CH1, i.e. in TIMx_CCMR1 you have to select CC1S=0b01.
> wouldn't CH1/CH2 pins have to be floating?
The point of this trick is to assign NO pins to CH1 and CH2 in the GPIO AF matrix... thus there are no pins to be left floating.
JW