Page 1 of 1

PIC16F887 DELAY TIME

Posted: Thu Sep 27, 2018 3:33 pm
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.

Re: PIC16F887 DELAY TIME

Posted: Fri Sep 28, 2018 9:41 pm
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?

Re: PIC16F887 DELAY TIME

Posted: Mon Oct 01, 2018 1:24 pm
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.

Re: PIC16F887 DELAY TIME

Posted: Mon Oct 01, 2018 2:58 pm
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.