EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Timer 2 in compare mode

Timer 2 in compare mode

|

Microcontroller › 8051 › Timer 2 in compare mode

  • This topic has 1 reply, 2 voices, and was last updated 14 years, 9 months ago by romel emperado.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • May 14, 2011 at 2:56 pm #936
    Christian Wilhelmsen
    Participant

    Hi,

     

    I’m using an nRF24LE1 based on the 8051 architecture, so it is quite similiar.

    What I am trying to do is set up Timer 2 with interrupts each ~15ms, using the compare interrupt feature.

     

    my init routine is as such:

     

    void timer2_init()
    {
        uint16_t test_ms = 0x2710;    // 15ms, 10000
        T2CON |=    (1 << 7);         // prescaler = Fcpu/24, one tick equals 1.5µs
        T2CON |=    (1 << 2);        // Compare mode, Mode 1 (16 bits timer)
        T2CON |=    (1 << 0);        // Start timer 2 with f/12 of f/24         
        CCEN   =    (1 << 1);        // Compare with CRC
        IEN0  |=    (0x01 << 5);    // Enable Timer2 interrupt

        CRCH = (test_ms << 8);
        CRCL = test_ms & 0xFF;
    }

     

    Never the less, the interrupt only occurs each 100ms, and I just can’t understand why. In the interrupt, I make sure to clear the TF2 bit.

     

    Any help on this issue is really much appreciated, since I have an assignement controlling a helicopter due in one week!

    May 16, 2011 at 6:32 am #6222
    romel emperado
    Participant

    What I am trying to do is set up Timer 2 with interrupts each ~15ms, using the compare interrupt feature.

     

     

    —I dont quite understand your problem… pls more info..

     

     

    and about the TF2 bit. I dont think you need to clear the TF2..

     

    Timer 2 Overflow (TF2.). This bit is set when T2 overflows. When T2 interrupt is enabled, this bit will cause the interrupt to be triggered. This bit will not be set if either TCLK or RCLK bits are set.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • ANOTHER OLD PROJECT REDO February 7, 2026
  • Do i need a buffer? February 7, 2026
  • wall transformer polarity February 7, 2026
  • Supply vs performance query February 7, 2026
  • BPF February 7, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise