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 / Problem with multisim timer program

Problem with multisim timer program

|

Microcontroller › 8051 › Problem with multisim timer program

  • This topic has 0 replies, 1 voice, and was last updated 13 years, 2 months ago by john.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • March 9, 2012 at 4:58 pm #1588
    john
    Participant

    Hello all,

                 I am currently having trouble building this timer counter program in multisim. It seems to compile okm in keil. however in multisim

    I get two “constant expression required” error messages.Any help would be greatly appreciated as this is holding up the rest of my project as i need to use an interrupt to compare the two values (frequencies) in the timers.

     

    Thanks for any input,

     

     

    MY SAMPLE

     

                 
      

    #include<htc.h>

    #define TRUE 1
    #define FALSE 0

    bit LED=P1^2;
    void delay(void);//50us delay;
        
    static void delay1(void){//set up for 1ms delay
        char c;
        for(c=0;c<20;c++){
        delay();
        }
        }

    bit On_Off=P1^0;//On-Off switch on P1^0//(Starts device)

    //function to see if switched is pressed
    bit SwitchOn_Off(void);

    //50ms debounce function
    void debounce (void);

    //function to count the pulses received on the timer input pins(T0 and T1)
    void Pulsecount(void);
    void delay(void);//50us delay;

    void main (void){

    while (TRUE){

        if (SwitchOn_Off()==TRUE){
        LED=0;

        Pulsecount();//initiate count

    }
        else{}//do nothing

    }
    }

    bit SwitchOn_Off(void){

        if(On_Off==FALSE){//If switched is closed(0)
            debounce();//carry out switch debounce(delay Procedure)
            return TRUE;//Returns TRUE to allow operation to carry on
        }
            return FALSE;//function returns a FALSE
        }

    void debounce (void){

    TL0=0xb0;
    TH0=0x3c;
    TMOD=0x01;
    TR0=1;
    TF0=0;
    /*sets timer0 as interval timer and loads the decimal value
    15536 in to it;;leading to it being incremeneted 50000 times
    before it overflows;;ie TF=1(50ms)*/
    while (TF0==FALSE){}
        TR0=FALSE;
        TF0=FALSE;
        }

    void Pulsecount(void){

    while(TRUE)
        
        T0=1;//set T0 as input pin(therefore increments Timer0 as pulse goes from low to high
        T1=1;//set T1 as input pin(therefore increments Timer1 as pulse goes from low to high

        TMOD=0x55;//sets Timers in 16bit interval timer mode
        
        //clear any values in timers
        TH1=0;
        TL1=0;
        TH0=0;
        TL0=0;

        TR1=TRUE;//start timer1
        TR0=TRUE;//start timer0
        delay1();
        TR1=FALSE;
        TR0=FALSE;

    }

     void delay (void){
     char c;
     for(c=0;c<16;c++);//50us delay
     }
     
     

     

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

RSS Recent Posts

  • Wish to buy Battery, Charger and Buck converter for 12V , 2A router May 13, 2025
  • Need Help Figuring Out the Schematics Of Circuit Board May 13, 2025
  • applying solder paste from a jar May 12, 2025
  • Question i-nears headphones magnetic drivers May 12, 2025
  • An Update On Tarrifs May 12, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 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