About timer operation in 8051 micro controller

I AM STUDYING MICROCONTROLLER 8051 SUBJECT, WHILE DOING PROGRAM OF TIMER OPERATION, I HAVE FOUND SOME PROBLEM IN THE MODE 2 OF TIMER OPERATION IN WHICH CONTENTS PRESENT IN THx IS AUTO RELOADED INTO THE TLx AND WHEN TLx BECOMES 00H TFx FLAG GOES HIGH AND CONTENTS AGAIN AUTO RELOADED INTO THE TLx FROM THx.
BUT THERE IS A PROBLEM WHEN TIMER STARTS BY SETTING THE TRx BIT HIGH, THE TLx STARTS FROM 00H INSTEAD OF STARTING WITH THE CONTENTS OF THx. TLx ALWAYS STARTS WITH 00H.
I HAVE ALSO ATTACHED THE IMAGE OF MY PROGRAM THAT I HAVE WRITTEN IN KEIL SOFTWARE WHERE IN THE RED CIRCLE I HAVE SHOWN THE CONTENTS OF THE TH AND TL REGISTER.

Replies

  • Harshad Italiya
    Harshad Italiya
    #-Link-Snipped-# can you share your keil project .zip file here?
  • sparsh sharma
    sparsh sharma
    Harshad Italiya
    #-Link-Snipped-# can you share your keil project .zip file here?
    #-Link-Snipped-#
    i have written just a small program to check the working of timer in mode 2.
  • IanSiladi
    IanSiladi
    The problem is looking in your code. Are you enable to put the count that should be copied into the TL from the TH?
    Also what about your interrupt handling?
    Are you using any kind of the hardware interrupt here, specially for your timer-counter?

    #-Link-Snipped-#
  • sparsh sharma
    sparsh sharma
    IanSiladi
    The problem is looking in your code. Are you enable to put the count that should be copied into the TL from the TH?
    Also what about your interrupt handling?
    Are you using any kind of the hardware interrupt here, specially for your timer-counter?
    This code is written just for the purpose of understanding the Timer operation in MODE 2 of 8051uc. i have also simulate it on keil uvision3 software. the snap shot of the output i have attached.
    and count in TL0 is loaded with TH0 contents only if TF0 is made high internally, initially TL0 starts with 00h.
    and about interrupt i am using the polling/status check method not using any hardware interrupt.
    just checking the TF0 bit status
  • Harshad Italiya
    Harshad Italiya
    #-Link-Snipped-# :
    8051 Timer 0 Mode 1 Example Program
    8051 Timer 1 Mode 2 Example Program
    You can find Timer 0 example code from KEIL. Try this and see if this is working for you properly or not.
  • sparsh sharma
    sparsh sharma
    Harshad Italiya
    #-Link-Snipped-# :
    8051 Timer 0 Mode 1 Example Program
    8051 Timer 1 Mode 2 Example Program
    You can find Timer 0 example code from KEIL. Try this and see if this is working for you properly or not.
    yes its working but with the same way as i have mentioned, there is a need to load the TLx register first, there is no auto reload initially in this mode2. auto reload happens only after the generation of Timer Flag internally.
    Thanks
  • Harshad Italiya
    Harshad Italiya
    sparsh sharma
    yes its working but with the same way as i have mentioned, there is a need to load the TLx register first, there is no auto reload initially in this mode2. auto reload happens only after the generation of Timer Flag internally.
    Thanks
    I am still not getting you. Have you checked what is the difference between your code and the example code?
  • sparsh sharma
    sparsh sharma
    Harshad Italiya
    I am still not getting you. Have you checked what is the difference between your code and the example code?
    yes i checked, there is no difference, both are same
    thank you sir

You are reading an archived discussion.

Related Posts

Indian smartphone manufacturer Micromax has put up its new smartphone, the Canvas Amaze for sale. A few days after surfacing on the company’s official website, the Micromax Canvas Amaze went...
how to choose any specific filed , like engineering , doctor , Vakil etc
what are the ways to increasing efficiency air conditioner?
Besides working on cell phones and being a telecommunications services company, Huawei has also been working on bringing new technologies to market. In the first of such work, Huawei has...
Yesterday, Mr. Piyush Goyal Hon'ble Minister of State with Independent Charge for Power, Coal, New and Renewable Energy in the Government of India declared in a tweet that they have...