Menu

16F887: External clock ISSUE when using in Proteus

Help
sfyris
2019-09-04
2019-09-09
  • sfyris

    sfyris - 2019-09-04

    This simple code supposed to give on portb.0 variable pulse width, depending on the position of the potensiometer in the attached circuit diagram connected as stated in page 65 of the chip manual.

    ;Chip Settings
    #chip 16F887,20
    #config OSC=EXTRCIO
    ;Variables
    Dim count As word
    
    dir portb.0 out
    do forever
        for count = 1 to 200
        next
        set portb.0 on
        for count = 1 to 200
        next
        set portb.0 off
    loop
    

    well....instead, as you can see in attached image, the pulse width is steady about 25ms in every position of the potensiometer (and for 20MHz->R=160ohm, C=47pF it should be very narrower). Additionaly no clockout pulses in channel B of oscilloscope as it would happen as stated again in chip manual. Only when I change the clock to internal 8MHz it changed to 1ms which is normal value for this frequency. It seems that the chip dont regognize my setting to external rc clock surce. Any suggestion? (even when changing the values of R and C in the stated limits nothing happens...)

     

    Last edit: Anobium 2019-09-05
  • Anobium

    Anobium - 2019-09-05

    Incorrectly posted. I have moved to Help.


    Looks to me that your external oscillator is incorrect. Does this help?

    #config OSC=EXTRC_CLKOUT
    
     
  • sfyris

    sfyris - 2019-09-05

    no option of external oscillator is working
    Tried any

     
  • Anobium

    Anobium - 2019-09-05

    In the simulator? or, real chip?

     
  • sfyris

    sfyris - 2019-09-05

    No in real I dont tried yet. Only in sim

     
    • Anobium

      Anobium - 2019-09-05

      As I do not have Proteus I can investigate.

      Works in my SIM.

      Someone else able to help?

       
  • sfyris

    sfyris - 2019-09-06

    back to reality...but with something different now. In attached foto you see my ext connection of a crystal oscillator. A 20MHz crystal, two capacitors of 47p....bla bla...at pins 13-14...Nothing simple like that. But the 16f887 don't seems to run that fast. It seems to go at 4MHz internal osc. And the code (the # symbol is gone at copy - paste don't know why, it is there in the code)

    chip 16f887,20

    config OSC=HS

    bla bla bla.....

     

    Last edit: sfyris 2019-09-06
  • Chris Roper

    Chris Roper - 2019-09-06

    Try removing the Capacitors and place the xtal as close to the target pins as you can to eliminate the fly /patch leads.

    I know that sounds strange and not at all intuitive but those plastic Breadboards have a very high stray capacitance and could be adding to your chosen value.

    I have successfully run at 20MZ without the Capacitors, but if more capacitance is needed start low, I would probably not go higher than 22pF.

     

    Last edit: Chris Roper 2019-09-06
  • Chris Roper

    Chris Roper - 2019-09-06

    Here is a Breadboard circuit that I used for a PIC32.
    This Circuit worked well and I used it for several tutorials.

    It is not the PIC16 that you use but it does show what I had in mind for getting your oscillator circuit closer to the device.

    I would also remove any Config derivatives, let GCBASIC use the defaults.

     
    ❤️
    1

    Last edit: Chris Roper 2019-09-06
  • sfyris

    sfyris - 2019-09-06

    Ok XTAL issue solved, NO NEED FOR CAPACITORS. When I put them back chip goes down to 4MHz. The position on the breadboard seems not critical (to me anyway). Now remains the other issue, that with the sim and the ext rc osc...thank you Mr Roper. And yes you have right, GCB sets by itself the configuration, no need for derivatives. What a lovely language.

     

    Last edit: sfyris 2019-09-06
    • Chris Roper

      Chris Roper - 2019-09-06

      My Pleasure sfyris, I am glad I was able to help.

       
      👍
      1

      Last edit: Chris Roper 2019-09-06
  • sfyris

    sfyris - 2019-09-08

    Well, as for the sim issue, one solution I found is going in the settings of the chip and set the frequency by hand. Ok a little tricky but it works.

     

Log in to post a comment.