473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to calculate Prescalar and Modulus values for PIT (Programmable Interrupt Timer)

365 100+
How to calculate Prescalar and Modulus values for PIT (Programmable Interrupt Timer). I have microcontroller running at 60MHz. I am thinking of writing 1 milli sec ISR for PIT. I need to calculate prescalar value and modulus value for PIT, prescalar value between 0 and 15, but how can I choose which value for 1ms timer at 60MHz system clock running?. appreciated.
Nov 10 '09 #1
4 5649
donbock
2,426 Expert 2GB
The hardware documentation for your PIT ought to explain how timer clock frequency is derived from the chip clock frequency. You may have the choice of several timer clocks due to divider options in a control register. Once you know the timer clock frequency it is a simple matter to compute the counter value (prescalar and modulus) that yields the desired timer frequency.

I know this is a very general reply, but I don't know what hardware you're using.
Nov 10 '09 #2
newb16
687 512MB
It's prescalEr first of all. Then you need overall divisor: 60 mhz/1 khz = 60000. Lets suppose that the timer is 8-bit and supports only values of Modulus(?) up to 255, and suppose that prescaler is dividing main clock frequency by 2**N where N is from 0 to 15, select smallest N such that 60000/(2**N) is less than 255. If timer is 16-bit, the prescaler may be left unused (1:1) and modulus set to 60000.
Nov 10 '09 #3
tvnaidu
365 100+
I am using general PIT, there is 4 bit prescalar and modulus register, prescalar value tells like this:

PRE system clock div
0000 2
0001 4
0010 8
0011 16
0100 32
0101 64
0110 128
0111 256
1000 512
1001 1024
1010 2048
1011 4096
1100 8192
1101 16384
1110 32768
1111 65536

I just need to calculate mod using pre, they didn't give how to derive mod.
Nov 10 '09 #4
donbock
2,426 Expert 2GB
For example, if you set the Prescaler to 256 then the timer clock frequency is (60MHz/256). It will take (0.001)*(60,000,000)/256 clock ticks to count out 1 mS. You can perform a similar calculation for each prescaler setting.

There will typically be a small error of about half the timer clock period due to integer round-off of the computed modulus value.

The computed result will be too big to fit in the Modulus register for smaller prescaler settings. Choose a prescaler/modulus combination where the modulus value fits in the modulus register and where rounding error is minimized.

This is still a general answer. Your specific timer hardware may do something different that I'm not aware of.
Nov 10 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark | last post by:
Hello all, I know why the following doesn't work ... I can't figure out how to make it work like I want it to. Basically, I only want the loop computing fibonacci numbers to run for approx 5...
19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
41
by: Saurabh Saxena | last post by:
can we calculate the 73! value in c or c++ without loss of significant digits.
10
by: jantod | last post by:
I think there might be something wrong with the implementation of modulus. Negative float values close to 0.0 break the identity "0 <= abs(a % b) < abs(b)". print 0.0 % 2.0 # => 0.0 print...
5
by: mysli | last post by:
Hi all, I need to write a ISR using Microsoft VC++ 2005. The proplem is I did not found any hint on how to do it. I can register any function as a ISR and it will be called by the hardware...
2
by: mscdex | last post by:
I have a server application that accepts file transfers (utilitzing tcplistener) and was wondering how I would efficiently go about determining the calculate transfer rate while I am transferring...
0
by: gbagur | last post by:
Does anybody has an example code of using the timer interrupt? I need to generate an event every 33ms. Thank you!
2
by: Eirik Midttun | last post by:
I have seen quite a few times that C programs contain a file named isr.c or files named a_isr.c, b_isr.c where a and b are hardware that generate interrupts. Obviously these files contain code to...
1
by: symmer | last post by:
Hello, I am familiar with C language.But I have never tried working on Interrupt routines or Timers. Please help me write a interrupt routine for waiting for an event to occur. If an event...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.