cancel
Showing results for 
Search instead for 
Did you mean: 

Count edge with TIM14 channel 1 ?

MM..1
Chief III

I use counting on TIM15 and now need change to 14 , but seems here external pulses counting dont work. FYI STM32F030

Is any setup for 14 possible?

1 ACCEPTED SOLUTION

Accepted Solutions

TIM14 does not have the "slave-mode controller" i.e. there's no external clock possible, it's a very much stripped down basic timer.

Can't you use something else? Which 'F030 (different packages are different chips)? Which pin?

JW

View solution in original post

13 REPLIES 13
moatjon
Associate III

Hey MM,

Can you give us some more information? Are you trying to increment a counter based on an external pulse? What chip are you using?

Kind regards,

moatjon

MM..1
Chief III

External pulses is high speed need hw counting., this works for me on TIM15

	RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM15,ENABLE);
	
  TIM_Initstruct.TIM_Channel = TIM_Channel_2;
  TIM_Initstruct.TIM_ICPolarity = TIM_ICPolarity_BothEdge;
  TIM_Initstruct.TIM_ICSelection = TIM_ICSelection_DirectTI;
  TIM_Initstruct.TIM_ICPrescaler = TIM_ICPSC_DIV1;
  TIM_Initstruct.TIM_ICFilter = 0x00;
	TIM_ICInit(TIM15,&TIM_Initstruct);
	
	TIM_TIxExternalClockConfig(TIM15,TIM_TIxExternalCLK1Source_TI2,TIM_ICPolarity_BothEdge,0);
	
	TIM_Cmd(TIM15,ENABLE);
	TIM_SetCounter(TIM15,1); //workaround
	lastTIM15=TIM_GetCapture2(TIM15);

moatjon
Associate III

Are you using CubeIDE / CubeMX to generate your code? If so, can you share the .ioc file or show the TIM15 configuration? Is TIM14 channel 1 connected to the relevant pin?

??? no no yes

TIM14 does not have the "slave-mode controller" i.e. there's no external clock possible, it's a very much stripped down basic timer.

Can't you use something else? Which 'F030 (different packages are different chips)? Which pin?

JW

moatjon
Associate III

You have to give some more information. What setup have you tried for TIM14? Does it not work if you replace the TIM15 instances with TIM14? When you say "external pulses counting dont work" does that mean that the counter stays at 0?

Yes i see reference TIM14 is ... , and yes if dont exist way i rearange PCB , but first ask is any possible solution to count pulses on PA4 pin.

I try count in exti but pulses is lost sometimes.

I don't see any possible trick for PA4, sorry.

Maybe there's some room for improvement for the EXTI (aggressive rewrite in asm, maybe using registers snatched from the compiler if using gcc).

The timer input capture interrupt may provide the same service as EXTI. If your usage case allows it, you could use the input capture prescaler to reduce the interrupt rate thus possibly eliminate interrupt loss, at the cost of count granularity.

JW

Thanks Jan,

any interrupt seems here is slow because is delayed with other or systicks .

Maybe i can change source signal to wide coded, then TIM14 can measure width by CC hw, have you any example howto setup TIM14 input capture to measure one pulse width , optimaly one edge reset TIM and second store CC1