Page 1 of 1

Wrong timing using internal Clock 16F88 & 12F683

Posted: Tue May 03, 2011 12:45 pm
by GerhardB
Hi,

in a test programm a port pin should toggle
100ms on / 100ms off, but when I measure the port pin signal,
I get wrong pulse timings (see below). (internal clock OSCCON=0x60 => 4MHz)
PIC16F88_Test01.fcf
(4.5 KiB) Downloaded 255 times
here in use:
FlowCode for PIC 4.3.7.63 Prof.
Multiprogrammer EB-006-00-7


used settings:
Project options:
watchdog: off
Chip settings (PIC16F88 or PIC12F683):
Oscillator Selection: INTRC as Clock Out to measure the uC clock/4
all other options: off or disable

Here are the different test settings and test results:

FlowCode FlowCode
project OSCCON OSC2 set pulse pulse width
clock set out width measured

8000000 0x60 1MHz 100ms 288.0ms
4000000 0x60 1MHz 100ms 235.4ms
2000000 0x60 1MHz 100ms 213.0ms
1000000 0x60 1MHz 100ms 190.4ms
500000 0x60 1MHz 100ms 190.4ms

4000000 0x70 2MHz 100ms 117.0ms
4000000 0x60 1MHz 100ms 235.4ms
4000000 0x50 500kHz 100ms 471.2ms
4000000 0x40 250kHz 100ms 943.2ms
4000000 0x30 125kHz 100ms 1887.0ms

With both PIC12F683 or PIC16F88 I can reproduce it.

When I vary the "OSCCON" setting, the pulse widths are not correct,
but they are changing proportinal at least.

When I vary the "FlowCode project clock", the pulse widths are also wrong but changes
in a strange way.


But where is the bug?
How can I get the correct pulse widths?

Thanks for any help!

p.s.: using a 19.6608MHz crystal the pulse width is 96.8ms

Re: Wrong timing using internal Clock 16F88 & 12F683

Posted: Tue May 03, 2011 1:21 pm
by medelec35
GerhardB wrote:But where is the bug?
How can I get the correct pulse widths?

Thanks for any help!
Hi GerhardB,
The problem is caused by 'Auto Clear Watchdog' (in 'View', 'Project options') enabled.
When enabled, extra clear watchdog commands are accessed to stop Watchdog time out occurring.
If you untick the option, then you will find each delay will be reduced to 100ms.

Martin

Edit just remembered about a couple of threads.
See:
http://www.matrixmultimedia.com/mmforum ... 495#p14393
and
http://www.matrixmultimedia.com/mmforum ... =30&t=6702

Re: Wrong timing using internal Clock 16F88 & 12F683

Posted: Tue May 03, 2011 10:41 pm
by GerhardB
Hi Martin,

thanks a lot, it solved the problem.

Gerhard

p.s.: I could'nt find threats to this problem, I think I used the wrong search terms.

Re: Wrong timing using internal Clock 16F88 & 12F683

Posted: Wed May 04, 2011 1:17 pm
by medelec35
Hi Gerhard,
Your welcome.

Np about the links. I roughly knew what to search for as I have contributed on the threads.
You did not have that advantage.

I don't always find what I'm searching for either :P
Martin