2019-08-07 04:43 AM
R is 10k, and c 1uf, vcc 3.1 , charge to full,
i then captured the rising edge, but time counter changes every time
static void TIM1_Config(void)
{
TIM1_ICInit( TIM1_Channel_2, TIM1_ICPolarity_Rising, TIM1_ICSelection_DirectTI,
TIM1_ICPSC_DIV2, 1);
/* Enable TIM1 */
TIM1_Cmd(ENABLE);
/* Clear CC1 Flag*/
TIM1_ClearFlag(TIM1_FLAG_CC2);
//printf("xxbbbb %u\n", TIM1_GetCapture2());
printf("%02x \n", TIM1->SR1);
/* wait a capture on CC1 */ // CC1IF
while((TIM1->SR1 & TIM1_FLAG_CC2) != TIM1_FLAG_CC2);
/* Get CCR1 value*/
ICValue1 = TIM1_GetCapture2();
printf("capture value %u\n", ICValue1);
TIM1_ClearFlag(TIM1_FLAG_CC1);
}
2019-08-07 11:39 AM
A problem with this plan is that you don’t know at what voltage the stm32 will regard its input at logic high, at which point the timer-value will be captured.
This logic threshold can vary from chip-to-chip and also over temperature. And with that the proportion of the R-C time constant that you actually measure will change.
Perhaps it is time to step back and tell us what you are trying to achieve.
Hope this helps,
Danish
2019-08-07 05:41 PM
measure thermistor's R when capacitor is charged full (p1.2 270ohm gets high level )