View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19819
|
|
Posted: Sat Jul 28, 2018 2:36 am |
|
|
I doubt if the timings will work at 4MHz. The chip relies on quite accurate timings, and (for instance), an 'output_high' instruction will take 4uSec to execute at 4MHz. Not fast enough to work. |
|
 |
vmetal
Joined: 27 Jul 2018 Posts: 8
|
|
Posted: Sat Jul 28, 2018 2:57 am |
|
|
ok. But if I use 20MHz in proteus why it doesn't work? I make a new design in proteus but the result is the same.
Thanks for your reply. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19819
|
|
Posted: Sat Jul 28, 2018 4:37 am |
|
|
You probably have something in the project setup wrong.
We hate Proteus. It is buggy and results in projects that often cannot work, yet will then say that 'known working' code won't work.
If you have any question involving Proteus, go and ask it on a Proteus forum.
Now there may be something about your project that is setup wrong in the hardware and Proteus is being quite correct in telling you this. However this needs you to find it.
Step back and ensure that every connection that needs to be there is there. This includes things like decoupling really close to the chip. Pull up on MCLR. All the supply connections, etc. etc.. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9466 Location: Greensville,Ontario
|
|
Posted: Sat Jul 28, 2018 5:55 am |
|
|
If you're physically using a 4MHz xtal, then your #use delay(...) MUST be #USE delay(clock=4000000).
If it's still 20MHz then ALL the timings will be wrong (by 5 actually).
I checked an old test PC here and I do have 16F877 code with 4MHz clock. While I don't have the hardware to test, pretty sure it ran fine, years ago. I still have a bag of 4MHz xtals and 22pf caps, probably why I grabbed them
I can't stress enough that Proteus is NOT the way to confirm your code is good. Too many bugs and bad DRCs. It is NOT reliable.
You should code/compile/test a '1Hz LED' program and CONFIRM the PIC is running at the correct speed. This should, no, MUST, be done before testing any other program.
Jay |
|
 |
vmetal
Joined: 27 Jul 2018 Posts: 8
|
|
Posted: Sun Jul 29, 2018 11:31 am |
|
|
I will try with 32Mhz crystal in my board with 18f25k50. I will write soon.
Thank you. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19819
|
|
Posted: Sun Jul 29, 2018 11:47 am |
|
|
Whatever crystal/chip you use, the very first thing to do _always_ is a basic test that the chip is working. A flash an LED test, and check it does give the times expected. Nothing is ever going to work 'right' unless this is working right. |
|
 |
|