+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Newbie level 3
    Points: 28, Level: 1

    Join Date
    Mar 2019
    Posts
    4
    Helped
    0 / 0
    Points
    28
    Level
    1

    PIC16F877A correct wiring and the external clock?

    Greetings.

    Im attempting to connect my first pic and have it blink an led with a simple program i wrote. However its not working and i could use some help.

    Everything works when i connect it on proteus 8 however when i try connect on breadboard it doesn't do anything. I dont know if some crystal is needed to be connected to OSC1 and OSC2? I connected 5V to both Vdd pins and ground to both Vss. and an led to pin 15 the RC0.

    I did manage to use MPLABxIPE to program the pic so im glad i at least did something right :D

    I'm using a PIC16F877a and here is the code i wrote:

    Code:
    void main() 
    {
     PortC = 0;
     TrisC = 0b00000000;
     ADCON1 = 7;
     CMCON = 7;
     while(1)
     {
      RC0_bit = 1;
      Delay_ms(1000);
      RC0_bit = 0;
      Delay_ms(1000);
     }
    }
    Any guidance is much appreciated.

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 263,400, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    46,024
    Helped
    13996 / 13996
    Points
    263,400
    Level
    100

    Re: PIC16F877A correct wiring and the external clock?

    PIC16F877 has RC oscillator as simple clocking option, but no internal oscillator. Review datasheet chapter 14 for details.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 80,237, Level: 69
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    16,278
    Helped
    3692 / 3692
    Points
    80,237
    Level
    69

    Re: PIC16F877A correct wiring and the external clock?

    Hi,

    Proteus doesn't care about
    * clock circuit,
    * power supply, it's impedance and correct use of capacitors
    * current drawn by the circuitry connected to the ports
    * floating ports
    And so on.

    Thus by far not every circuit that works on Proteus will run in reality.

    If you want us to check your circuit, show us your complete schematic and post a couple of photos.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 2
    Points: 3,827, Level: 14
    Achievements:
    7 years registered

    Join Date
    May 2012
    Posts
    510
    Helped
    118 / 118
    Points
    3,827
    Level
    14

    Re: PIC16F877A correct wiring and the external clock?

    You have not defined the configuration bits. Proteus may not care about this, but the hardware does.


    1 members found this post helpful.

  5. #5
    Newbie level 3
    Points: 28, Level: 1

    Join Date
    Mar 2019
    Posts
    4
    Helped
    0 / 0
    Points
    28
    Level
    1

    Re: PIC16F877A correct wiring and the external clock?

    What does the pic use this internal RC oscillator for if its not for the processor?

    Thank you so muchfor clarifying this! I was confused why the pic would work with/without an oscillator on Proteus but that wasn't the case on hardware.



  6. #6
    Newbie level 3
    Points: 28, Level: 1

    Join Date
    Mar 2019
    Posts
    4
    Helped
    0 / 0
    Points
    28
    Level
    1

    Re: PIC16F877A correct wiring and the external clock?

    Forgive me i forgot to mention i used MikroC for PIC to write the code and it seems to have a nifty way of setting configuration bits before you begin writing the code. I have attached a picture of what i think it we are talking about please take a look.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	4 
Size:	112.6 KB 
ID:	152151



  7. #7
    Super Moderator
    Points: 263,400, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    46,024
    Helped
    13996 / 13996
    Points
    263,400
    Level
    100

    Re: PIC16F877A correct wiring and the external clock?

    So what? All these options are discussed in the data sheet in detail.

    As already explained, you need to select a valid clocking method, provide the required components, either crystal, ceramic resonator, RC circuit or external oscillator and program the option respectively.

    The other config bits listed in your post have various purposes. You don't need to learn all at once and can keep the default setting for the time being.

    Or use a recent PIC with internal oscillator and save the additional external hardware.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  8. #8
    Newbie level 3
    Points: 28, Level: 1

    Join Date
    Mar 2019
    Posts
    4
    Helped
    0 / 0
    Points
    28
    Level
    1

    Re: PIC16F877A correct wiring and the external clock?

    Quote Originally Posted by FvM View Post
    So what? All these options are discussed in the data sheet in detail.

    As already explained, you need to select a valid clocking method, provide the required components, either crystal, ceramic resonator, RC circuit or external oscillator and program the option respectively.

    The other config bits listed in your post have various purposes. You don't need to learn all at once and can keep the default setting for the time being.

    Or use a recent PIC with internal oscillator and save the additional external hardware.
    Ok noted thank you Sir.



--[[ ]]--