PAUSEUS does not working properly (wrong timing)


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default PAUSEUS does not working properly (wrong timing)

    Hello.

    Here's simple code:

    Code:
    define OSC 4
    TRISB = %00000000
    charte var PORTB.2
    gamorte var PORTB.3
    
    AGAIN:
    pulsout charte,1
    pauseus 100
    pulsout gamorte,1
    pause 1000
    pulsout charte,1
    pauseus 200
    pulsout gamorte,1
    pause 1000
    pulsout charte,1
    pauseus 300
    pulsout gamorte,1
    pause 1000
    
    
    GOTO AGAIN
    When run on 16F628A, instead of 100, 200 and 300 uS delays, it gives: 290, 400, 490us delay, measured with digital scope.

    I've modified code for 16F819, for 8mhz oscillator, by changing to: define OSC 8 and adding: OSCCON=%01110100

    In this case, linearity improved, but PAUSEUS are still out of definitions:

    100uS gives 270 uS
    200uS gives 370 uS
    300uS gives 470 uS

    Why this happens and what I'm doing wrong?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: PAUSEUS does not working properly (wrong timing)

    Hi,
    Are you sure you don't have the timebase setting on the scope set in the uncal mode, ie. not an even 1-2-5 whatever per division? Try something simple like
    Code:
    TRISB = 0
    Again:
       PortB.2 = 1
       Pause 500
       PortB.2 = 0
       Pause 500
    Goto Again
    That should give you a 1Hz toggle which would be easy enough to eyeball with a simple a LED. Then change to PAUSE 5 and check again with scope. I'm pretty sure it has nothing to do with the PAUSEUS statement in your code but rather something like the oscillator isn't running at the correct frequency or you're not measuring it correctly. But of course, I could be wrong.

    /Henrik.

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: PAUSEUS does not working properly (wrong timing)

    After you find your real timing problem, don't forget to consider the Pulsout statement execution time.

    I measured 47us delay between these signals running at 4MHz:
    Code:
    AGAIN:
        PULSOUT PORTC.3, 1
        PULSOUT PORTC.3, 1
    GOTO AGAIN
    This showed 147us between the end of one to beginning of the next pulse:
    Code:
    AGAIN:
        PULSOUT PORTC.3, 1
        PAUSEUS 100
        PULSOUT PORTC.3, 1
        PAUSE 100
    GOTO AGAIN
    Louie

  4. #4
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: PAUSEUS does not working properly (wrong timing)

    Scope xefinetly not the case, and the pause statement is working properly. the problem is with pauseus statement and only on small durations. say, pauseus 1200 and above, give almost perfect result. it is very interesting fact that, pauseus 1, gives 200 us delay between pulsout statements on 16 f628a @ 4 mhz, and only 48 us delay on 12 f683!

  5. #5
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: PAUSEUS does not working properly (wrong timing)

    The define OSC 4 needs to be DEFINE OSC 4 though I think the default is 4Meg it might require a correct DEFINE statement to make it work.

    With the 12f683 internal oscillator you need both the DEFINE OSC and the OSCCON to make it work properly. Not sure with the 16F628 if you need a PCON statement in addition to the DEFINE OSC.

Similar Threads

  1. 16f688 NES controller not working properly
    By emerson in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 14th November 2011, 17:21
  2. DT_instantINT 16f690 not working... what am I doing wrong?
    By Heckler in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th November 2011, 14:34
  3. Serin timeout not working properly!
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 1st January 2010, 20:56
  4. LCD display not working properly
    By dilpkan in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 2nd February 2008, 07:43
  5. DATA command not working properly
    By khufumen in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd December 2004, 11:54

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts