PIC16F887 DELAY TIME

An area to discuss 8-bit PIC specific problems and examples

Moderator: Benj

Post Reply
SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

PIC16F887 DELAY TIME

Post by SILVESTROS9 »

Hello to all!
I made some tests with PIC16F887, to get some delays that I need for a code..I make a simple code to check the duration accuracy of delays...I note that for a delay 80μs at FC7 code the scope shows 100μs and for delay 5μs the scope shows 20μs....Is there something wrong with FC7 code configuration, or something else? ...at hardware there are a crystal 20.000 MHz , 2X22pF for crystal, and a led to check the code run...the test code run well, but the delay timing is wrong..I send you the test code for any idea about to how to have the correct timing...thanks.
Attachments
DEMO-04-PIC16F887.fcfx
(7.07 KiB) Downloaded 232 times
20180927_154718.jpg
20180927_154718.jpg (133.77 KiB) Viewed 5401 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: PIC16F887 DELAY TIME

Post by medelec35 »

Software delays won't be very accurate but should not be too far of the mark.
I Could be wrong but I Believe it's down to microchip's free compiler bloating the code to make the professional version look like its worth more than it is.
As we are only talking microseconds, the bloating should not make any difference to the working of hardware if microsecond delays are not required.
It's more normal to use millisecond delays.
I don't believe it's an issue with Flowcode?

Maybe C code for the delay can improve things?
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC16F887 DELAY TIME

Post by Benj »

Hello,

I agree with Martin, If you try the free 60-day trial of the XC8 pro compiler then you see the difference it makes especially with microsecond delays. The free XC8 is not bad at all for most users but is artificially bloated if you need very precise timings.

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: PIC16F887 DELAY TIME

Post by SILVESTROS9 »

many thanks medelec35 and Benj for info...I use Microchip PICkit-2 to load the code to pic mcu, so I import .EXE to that programmer.Until now I have not problems for delay timing..I need relative accurate delays in the area 5-100μs. Is anything else that I can do to impove the accuracy? Instead of delays is it possible to use pulse? How can I have a pulse in that area with FC7? thanks.

Post Reply