CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ds18b20 pic16f876A
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Sat Jul 28, 2018 2:36 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jul 28, 2018 2:57 am     Reply with quote

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: 19215

View user's profile Send private message

PostPosted: Sat Jul 28, 2018 4:37 am     Reply with quote

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: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jul 28, 2018 5:55 am     Reply with quote

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 Smile

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

View user's profile Send private message

PostPosted: Sun Jul 29, 2018 11:31 am     Reply with quote

I will try with 32Mhz crystal in my board with 18f25k50. I will write soon.

Thank you.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Sun Jul 29, 2018 11:47 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group