0

i am using stm8s cosmic c compiler and i am trying to config tim2 for 350uS(350uS should be the pulse width).

As per the reference manual tim4 is 16-bit with prescaler factor of 32768. I will be using internal 2mhz clock

my calculations are as follows:

1/2000000 = 0.0000005sec ~ 0.5uS 
if we use 128 prescaler
128 * 0.5us = 64uS 

I want each pulse to be of 350us, how do i calculate that! Please help maybe the calculations are wrong too, i am super confused.

I am trying to calculate it for 350us but i am not getting actual value, need guidence!

nyl
  • 1

1 Answers1

0

Use lowest value of prescaler.

As you mentioned tim2 is 16 bit. So you have the span of 65535 counts. Without prescaler (2^0), the counter can reach a value of 700(for 350us).

It depends on the accuracy you want, I would not use a prescalar for these settings.