Skip to main content
hdemi.1
Associate III
September 27, 2022
Question

I'm using the stm32f0 series. I have it right now, so I'm doing it with a signal generator. I want to count every rising edge of the signal my code is as below but it is not counting prope

  • September 27, 2022
  • 3 replies
  • 877 views

This topic has been closed for replies.

3 replies

gbm
Lead III
September 27, 2022

Use the measured signal input as timer clock input. You cannot use capture function reasonably at 10 MHz.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
hdemi.1
hdemi.1Author
Associate III
September 28, 2022

I don't quite understand what you mean, can you give an example?

Tesla DeLorean
Guru
September 27, 2022

How fast is the STM32 clocking?

Not counting properly? Please expand on what it is doing..

Should be using External Clock modes, probably not measuring cycles.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
hdemi.1
hdemi.1Author
Associate III
September 28, 2022

I expect it to count every time a rising edge in but it doesn't

waclawek.jan
Super User
September 27, 2022

> TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV2;

Why? (although I don't think this makes any difference in this particular case)

> TIM1->SMCR |= TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1| TIM_SMCR_TS_2 | TIM_SMCR_TS_1;

That's TIM1_SMCR.SMS = 0b110 = Trigger Mode.

You probably want 0b111 = External Clock Mode 1, don't you.

Plus all the questions of TeslaDelorean.

JW