Skip to main content
mayakk12
Associate II
February 25, 2012
Question

Timer value calculation

Posted on February 25, 2012 at 10:34

hi,

I am using STM32VL board.. In my application i am reading voltage for every 6.25micro sec. so i'm using timer TIM2 in interupt mode for that. can any one tell me what value i need to set fro prescaler and period.

Sys clock is 24Mhz and ADC clock is 12 MZ.

thanks a lot in advance

#timer-value
This topic has been closed for replies.

18 replies

sanjib
Associate III
January 3, 2014
Posted on January 03, 2014 at 09:58

sanjib
Associate III
January 3, 2014
Posted on January 03, 2014 at 14:33

Tesla DeLorean
Guru
January 14, 2014
Posted on January 14, 2014 at 15:50

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6mv&d=%2Fa%2F0X0000000bvS%2FfWnfhVEsHdscddFOAUFU2Xmnx8GbaZUf171KQDZ2h8c&asPdf=false
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
sanjib
Associate III
December 30, 2014
Posted on December 30, 2013 at 06:43

Tesla DeLorean
Guru
December 30, 2014
Posted on December 30, 2013 at 07:09

I have tried with using the system clock's internal oscillator which  is 16Mhz and APB1 prescalar as 1 which gives me tim2 also 16Mhz. It is giving me the interrupt after every 1 second as  have checked with CRO after setting the prescalr value to 16000 and timer count to 1000. but why it is giving me 9 us interrupt when I am setting the prescalar to 0 and timer count to 25. It should give me 1.5625 us

Having the processor interrupt every 25 cycles, is perhaps, somewhat ill-conceived? Try having the hardware do the heavy lifting, and interrupt less frequently.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
sanjib
Associate III
December 31, 2014
Posted on December 31, 2013 at 10:25

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6nY&d=%2Fa%2F0X0000000bvh%2FZ9WnW3SknqqkshOVp.wHlu1bKgkkA56jSrhKpOUW9HM&asPdf=false
sanjib
Associate III
December 31, 2014
Posted on December 31, 2013 at 10:30

 the prescalar value is 2 and the timer count is 50. The sys clk is 128000000 and the tim2 frequency is 64000000

Tesla DeLorean
Guru
December 31, 2014
Posted on December 31, 2013 at 15:19

I really don't want to get dragged into doing your job here.

161 MHz? 160 KHz

Your choice of channels is neither configured correctly, or addresses availability of resources on the STM32F4-Discovery board.

How do you think sending dozens of characters at 9600 baud (say 960 chars per second) is remotely enough for the speed at which you are taking samples?

I don't think I'd be sequencing the samples in this fashion, and would probably use DMA+TIM.
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..