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...)
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)
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
Incorrectly posted. I have moved to Help.
Looks to me that your external oscillator is incorrect. Does this help?
no option of external oscillator is working
Tried any
In the simulator? or, real chip?
No in real I dont tried yet. Only in sim
As I do not have Proteus I can investigate.
Works in my SIM.
Someone else able to help?
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
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
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.
Last edit: Chris Roper 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
My Pleasure sfyris, I am glad I was able to help.
Last edit: Chris Roper 2019-09-06
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.