Monday, July 8, 2013

Counters and Timers

Many microcontroller applications require the counting of external events, such as the frequency of a pulse train, or the generation of precise internal time delays between com­puter actions. Both of these tasks can be accomplished using software techniques, but software loops for counting or timing keep the processor occupied so that other, perhaps more important, functions are not done. To relieve the processor of this burden, two 16-bit up counters, named T0 and T1, are provided for the general use of the programmer. Each counter may be programmed to count internal clock pulses, acting as a timer, or pro­grammed to count external pulses as a counter. 


 

TCON(TIMER/COUNTER CONTROL REGISTER)
  1. To control the timer/counter we need TCON register.
  2. its bit addressable
  3. address:88h
 

TMOD(THE TIMER MODE CONTROL REGISTER)
  1. it dedicated two timer.
  2. it is byte addressable
  3. address:89h
 

Timer Mode
The timers may operate in anyone of four modes that are determined by the mode bits, M I and MO, in the TMOD register. Figure 12 shows the four timer modes.

Timer Mode 0

  • Setting timer X mode bits to 00b in the TMOD register.
  • theTHX register as an 8-bit counter and TLX as a 5-bit counter.
  • As an example, the 6 megahertz oscillator frequency would result in a final frequency to TH of 15625 hertz. 
  • The timer flag is set whenever THX goes from FFh to 00h

Timer Mode 1

  • the mode bits are set to 0lb in TMOD
  • Mode 1 is similar to mode 0 except TLX is configured as a full 8-bit counter when .

Timer Mode 2

  • Setting the mode bits to l0b in TMOD configures.
  • the timer to use only the TLX counter as an 8-bit counter. 
  • THX is used to hold a value that is loaded into TLX every time TLX overflows from FFh to 00h. The timer flag is also set when TLX overflows.
  • This mode exhibits an auto-reload feature: TLX will count up from the number in THX. overflow. and be initialized again with the contents of THX.

Timer Mode 3

    • Timer 1 in mode-3 simply holds its count. The effect is same as setting TR1=0. Timer0 in mode-3 establishes TL0 and TH0 as two separate counters.
    • Control bits TR1 and TF1 are used by Timer-0 (higher 8 bits) (TH0) in Mode-3 while TR0 and TF0 are available to Timer-0 lower 8 bits(TL0). 
      figure of Timer Modes

      49 comments:

      npeducations said...

      thanks for u r posts with diagrams which made me understand more easily.

      Unknown said...

      I say thank for you because you made me understand very quickly as well as remembering also easily...
      Thank you

      eebox said...

      Would it be possible to show sample CODE for all MODES ? MODE 3 seems complicated.

      ap2v said...

      Are you looking for Devops Training in gurgoan? AP2V Academy is the best option for you! We are one of the best DevOps Training providers Academy in Gurgaon, India. We Also conduct DevOps Training, AWS Training, GCP Course, Linux Courses training, etc. Online live interactive classrooms with lifetime recording videos & 24*7 support.

      ap2v said...

      Are you looking for AWS Training in Gurgaon? AP2V Academy is the best option for you! We are one of the best AWS Training provider academies in Gurgaon, India. We Also conduct DevOps Training, DevOps Training, GCP courses, Linux Courses training, etc. Online live interactive classrooms with lifetime recording videos & 24*7 support. For more information- 92103 33323.

      ap2v said...

      Are you looking for Python Training in Gurgaon? AP2V Academy is the best option for you! We are one of the best Python Training provider academies in Gurgaon, India. We Also conduct DevOps Training, GCP courses, Linux Courses training, AWS Training etc. Online live interactive classrooms with lifetime recording videos & 24*7 support. For more information- 92103 33323.

      ap2v said...

      Are you looking for Python Training in Noida? AP2V Academy is the best option for you! We are one of the best Python Training provider academies in Noida, India. We Also conduct DevOps Training, GCP courses, Linux Courses training, AWS Training etc. Online live interactive classrooms with lifetime recording videos & 24*7 support. For more information- 92103 33323.

      ap2v said...

      Are you looking for AWS Training in Noida? AP2V Academy is the best option for you! We are one of the best AWS Training provider academies in Noida, India. We Also conduct DevOps Training, GCP courses, Linux Courses training, Python Training etc. Online live interactive classrooms with lifetime recording videos & 24*7 support. For more information- 92103 33323.

      appu ghar said...

      The best water park in Gurgaon AppuGhar is one of the best waterparks to enjoy the most amazing and trending water slides and spread across an area of 10 acres,

      liboc davamart said...

      If you are looking for Insulin injection for diabetes in India? Don't look further, Libocdavamart provides 100% authentic medicines online and offline at affordable prices all over India with Attractive Discounts & Offers.

      Reiasindia said...

      Ready to Move Affordable Flats in Gurgaon. Reias India is providing the best Flats at a very affordable and reasonable price. the space is situated in a prime location in Gurgaon.

      Barman Eye Care said...

      Best Eye clinic in Gurgaon Barmen Eye Care clinic is a premier, multispecialty eye hospital in Gurgaon where we offer the world-class latest diagnostic and surgical technologies.

      Eduyush India said...

      Want to know more about the ACCA Subjects and what will be the syllabus like Business and Technology, Management Accounting and Financial Accounting you will gonna learn all about this topics in this blog Click here To learn more

      Reiasindia said...


      Book New Projects in Gurgaon, you can buy all pre-launch, under construction, or upcoming projects and property at a relevant price in the second largest city of Haryana.

      appu ghar said...

      Appu Ghar provides a low price for oyster water park tickets booking online . Get the best Deals & offer on Online tickets Booking at AppuGhar Gurgaon. Book Now.

      astrologer said...

      Looking for an online astrologer in Gurgaon? Look no further than Mahakali Jyotish Kendra. Our experienced astrologers can answer all of your questions about love, career, and more. Contact us today!

      Barman Eye Care said...



      Barmen Eyecare is One of the best Eye Care Clinic in Gurgaon, we have the most experienced eye surgeons Team. We have the Best technology, and painless treatments with hight class equipment

      Reiasindia said...

      Looking for the latest treatment for dry eye Syndrome in Gurgaon you are facing problems in wearing contact, driving at night, and Reddening of eyes. No worry Barman EyeCare Can solve all your dry eye-related problems

      Eduyush India said...

      Do you want to know about the IFRS Certification Course and CIMA or you want to know why do we need to get this qualification and how it will help you to grow your future.

      Reiasindia said...

      Are you Looking For a good Commercial Space in Gurgaon For your Office use. your search is Over now Reias India is providing the best Commercial property at good reasonable Price.you will get a work friendly Envirment

      manish said...

      If you are looking for car battery shop in Gurgaon? look no further, Manishbattery is the best option for you. Manishbattery provide a variety of car batteries in gurugram at affordable cost.

      astrologer said...

      If you are looking for a Husband-wife problem solution in Gurgaon? you should contact Mahakali Jyotish Kendra and consult with the best astrologer in Gurgaon.

      Eduyush India said...

      Do you want to know about the ACCA Exam Fees or any details regarding this certification like where you can get ACCA Online courses Study material, and the Semester Fees of this particular certification?

      astrologer said...

      looking for the best love problem solution specialist? Mahakali Jyotish Kendra is the best option for your problem solution. will give you the solution to your every problem and by which all of the issues of your life .For more information contact us now:+91-9582737907.

      Eduyush India said...

      The COSO Framework stands for the Committee of Sponsoring Organizations of the Treadway Commission. It is a framework that organizations can use to manage enterprise risk. If you want to know more about the History, components, and Principals of the COSO Framework read this blog now.

      AIHM said...

      Do you know which institute is best for civil services preparation? ACSA is the reputed and very famous Institute for Civil Services Coaching in Jaipur.

      Shadanga– Kerala’s Ayurveda said...

      Are you looking for a Ayurvedic massage for your weight loss woes? We have the perfect solution for you! Our ayurvedic massage therapy is a holistic technique that helps balance your body, mind and soul.

      aceheart said...

      ACE Heart Institute Leads work that has raised standards for cardiovascular treatment Best Heart Hospital in Mohali .ACE heart hospital provides the best treatment and believes in the most outstanding service and facilities at an affordable price.

      Shadanga– Kerala’s Ayurveda said...

      Panchakarma treatment is a way of healing your body using five elements: air, fire, water, earth and space. Shadanga is providing a complete detox treatment, and it can help with a wide variety of health issues. Panchakarma can help with anxiety, stress, and depression, as well as many other health problems.

      Eduyush India said...

      Do you want to learn about ACCA Eligibility , Duration, Registration, Fees .This course is designed in such a way that it will help you learn the fundamentals of accounting and finance to a level where you will be able to move on to more advanced courses. The course is divided into two parts: the first part focuses on accounting and financial reporting,

      SRV associates said...

      looking for best virtual CFO service in India. Whether you're a fast-growing startup or an established business, there's no denying the value of a solid CFO.The best virtual CFO service will save you time, money, and resources as we take care of all aspects of this important role for your company.

      Godrej Pest Control said...

      Cockroaches are among the most challenging pests to eradicate because they have incredible survival
      skills and have even been known to last one week without a head. One of the greatest treatments
      for cockroach control services, is
      offered by Godrej Pest Control in Gurgaon and is based on the gel formulation, which has been tried and tested by professionals.

      Godrej Pest Control said...


      The Certified pest control services in Gurgaon. Godrej pest control provides total Services for cockroaches, mosquitoes, rodents, bedbugs, pigeons, ants, honeybees, Termite, Spider, Fly completely devoted to removing all types of pest control-related problems with the use of state-of-the-art technology and non-toxic chemicals.

      sswing said...

      We take pleasure in our dedication to provide children the best possible care and education, making Sswingspreschool is the most reliable learning partner and daycare in Gurgaon. We encourage kids to explore, create, and dream in order to develop their foundations and get them ready for the future. We do this by putting extensive safety procedures and protocols in place, as well as a carefully prepared curriculum.

      JoGenii Online said...

      You can buy best learning toys for 3 year old kids. JoGenii will be a great place to find different toys and we offers the most affordable prices for educational toys. These types of wonderful toys are available as jigsaw puzzles, wooden puzzles, cubes, and brain teasers. Jigsaw puzzles and wooden puzzles are great to help learn about colours and shapes.

      Vishwakarma Automobiles said...

      The best car ac repair in Gurgaonis
      provided by Vishwakarma Automobiles.We offer high-quality,reasonably cost-effective AC services and promised excellent outcomes that are backed by a warranty.

      Haut Monde said...

      Looking for a 4 star hotel in Gurgaon? look no further than the Haut Monde Hotel.The hotel also offers a wide range of amenities for business travellers, including function rooms, boardrooms, and even a business centre. Plus, you'll have access to free Wi-Fi and high-speed internet throughout the hotel.All of these features make the Haut Monde Hotel the perfect place to stay during your visit to Gurgaon.

      NRS Kitchen said...

      NRSKitchen is one of the most reputable and best
      restaurant equipment Manufacturers in Delhi
      . It has more than 15 years of experience
      serving a number of industrial kitchens.We provide high-quality, specialist cooking equipment
      that is tailored to your needs.

      Vishwakarma Automobiles said...

      Gurgaon has plenty to offer in terms of auto repair. Highly equipped workshops at Vishwakarma Automobiles provide you the greatest services, excellent quality, best prices, and genuine spare parts for routine maintenance.
      The best car service in Gurgaon have the knowledge and tools necessary to do the task swiftly and correctly. Phone now.

      D' Art Effects said...

      Floral Metal Wall Decor By Darteffects Add some life to your walls with our metal wall decor. Our floral metal wall decor will make the perfect addition to any room. With a wide variety of colors and designs, you are sure to find the perfect wall decor for your home.

      SRV associates said...

      want to know about a company registration fees in Delhi or you want to Create your own company in Delhi at a fraction of the price. Get up and running quickly with the most professional, reliable, and affordable company registration service SRV Associates contact us Today.

      Eduyush India said...


      Best courses for Diploma in IFRS, Our special IFRS training arrives at a much lower cost than standard providers and proposes the flexibility to handle your study objectives, job, and life.

      Poshace said...


      Get the most bang for your buck withRefurbished Macbooks in India! We offer certified pre-owned Apple Macbooks at unbeatable prices and features.

      Soapboxstudios said...

      Soapbox Studios is the best photographer in Gurgaon. We specialize in wedding, family, and commercial photography. Our team is dedicated to providing you with excellent service and quality images.we offer a variety of services that will help make your photo experience unforgettable .

      sswing said...

      Best Preschool in Gurgaon and Activity Centre is one of the leading preschools in Gurgaon, builds a strong foundation for children’s future. We offers holistic education that meets international standards, it has a friendly, fun, warm, safe nurturing and stress-free environment.

      Poshace said...

      Are you looking for the best-refurbished macbook in India for your budget? We are excited to introduce you to our best macbook for your professional career. All our devices are working perfectly and are 100% tested for a better experience. It can help you to do heavy task and projects in an easy way and its powerful processor help you to gain unlimited faster experience. Battery life is very strong you don't need to worry about charge time to time. That's why we have a great business of refurbished macbook air India in the market

      NRS Kitchen said...

      NRSKitchen is one of the premier Bakery Equipment Manufacturer . The company has been providing top-notch bakery equipment for many years, boasting an excellent track record in terms of quality and efficiency. NRSKitchen has a wide range of products to choose from.

      Eduyush India said...

      Leading the sustainability movement, Eduyush provides ESG certification to businesses looking to have a beneficial influence on the environment, society, and government. Our thorough certification programme assesses a company's performance and practises in crucial areas including ethical governance, reducing carbon footprints, and employee wellbeing.

      Loomstay Official said...


      Hotels in Delhi NCR Loomstay is the ideal destination for comfort and elegance among. Our hotel, which is tucked away in the centre of the city, offers a seamless fusion of contemporary elegance and first-rate service and the best option for a memorable stay hotel in Delhi NCR thanks to its excellent location and attentive service.

      Related Posts Plugin for WordPress, Blogger...
      Subscribe to RSS Feed Follow me on Twitter!