+ Post New Thread
Results 1 to 4 of 4
  1. #1

    pic 16F876A is running slow on 20MHZ crystal i want to get 1 second delay

    please help

    •   Alt10th September 2013, 15:49

      advertising

        
       

  2. #2
    Member level 5
    Points: 1,285, Level: 8

    Join Date
    Nov 2012
    Location
    Nigeria
    Posts
    92
    Helped
    8 / 8
    Points
    1,285
    Level
    8

    Re: pic 16F876A is running slow on 20MHZ crystal i want to get 1 second delay

    Using hardware timer or delay counter? Is your crystal oscillator High speed type, ceramic resonator; did you select the correct capacitors with the type of crystal in use?



    •   Alt10th September 2013, 16:11

      advertising

        
       

  3. #3
    Advanced Member level 4
    Points: 7,332, Level: 20
    Venkadesh_M's Avatar
    Join Date
    Jun 2013
    Location
    Coimbatore, India
    Posts
    1,375
    Helped
    258 / 258
    Points
    7,332
    Level
    20

    Re: pic 16F876A is running slow on 20MHZ crystal i want to get 1 second delay

    check the config bits and use HS for 20MHz..

    in hitech compiler use
    Code C - [expand]
    1
    2
    3
    4
    
    #define _XTAL_FREQ 20000000 // in top
     
    for(i = 0; i < 40; i++)
    __delay_ms(25);



    •   Alt11th September 2013, 07:00

      advertising

        
       

  4. #4
    Full Member level 1
    Points: 1,289, Level: 8
    vicky001.iith's Avatar
    Join Date
    Aug 2013
    Location
    INDIA
    Posts
    113
    Helped
    37 / 37
    Points
    1,289
    Level
    8
    Blog Entries
    3

    Re: pic 16F876A is running slow on 20MHZ crystal i want to get 1 second delay

    Use timers for proper delay. If you need , I can help you with code.
    Or you can use :-
    Code:
    #define _XTAL_FREQ 20000000 // in top
    // OR you can use configuration bits also
    #pragma config FOSC=HSMP ,PLLCFG=OFF,IESO=OFF
    void delay_ms(unsigned int time) // Here TIME is in MILLISECONDS
    {
    //Delay part
        unsigned char pause, i = 0; //DECLARE PAUSE AS UNSIGNED CHAR
        short int temp = 0;
    
        temp = time;
        for (i = 0; i < 4; i++) {
            time = temp;
            while (time > 0) //LOOP UNTIL TIME IS GREATER THAN ZERO
            {
                pause = 112; //INITIALIZE PAUSE TO 255
                while (pause--); //DECREMENT PAUSE UNTIL IT BECOMES ZERO
                time--; //DECREMENT TIME AND LOOP BACK UNTIL IT BECOMES ZERO
            }
        }
    
    }
    Last edited by vicky001.iith; 11th September 2013 at 07:50.
    ***The mind is beautiful because of the paradox. It uses itself to understand itself.***



--[[ ]]--