Time mismatch in PAUSEUS


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2008
    Location
    New York US
    Posts
    46

    Exclamation Time mismatch in PAUSEUS

    Hi All,
    Made part of my project.It is works in programmed PIC and I found that instruction PAUSEUS give different reading in 1 uSec and 275 uSec.
    Code:
      'Processor pic16F84A
    DEFINE OSC 20 
    ' __config _HS_OSC & _WDT_OFF & _CP_OFF set manually in .inc file
    TRISA = $0F ' Set PORTA to all input
    TRISB = %00000000 ' Set all of PORTB to outputs
    PORTB = $00
    
    - - - - - 
    ' Code below gives 275uSec pulse on PORTB.0 as expected
    
    PORTB = %00000001
    PAUSEUS 270    '275uSEC  on PORTB.0
    PORTB = %10000001
    PAUSEUS 5   
    - - - - 
    ' Code below has to give 1 uSec pulse on PORTB.2
    'Really I found 4 uSec pulse  on PORTB.2 that is wrong
    PORTB = %00000100
    PAUSEUS 1
      - -  -- - -
    So maybe I made mistake.Would you like to help to correct my program or
    setting.
    Best Regards

  2. #2


    Did you find this post helpful? Yes | No

    Default

    If you read the section of the manual "PAUSEUS" there is
    a big chart that shows: a minimum delay of 3us for a 20mhz clock

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Try these three lines of asm code should give you 1 microsec delay @ 20 MHz. (Just experimenting with some simple asm code to break the ice)

    Code:
    @ goto	$+1
    @ goto	$+1
    @ nop
    Al.
    All progress began with an idea

  4. #4
    Join Date
    Dec 2008
    Location
    New York US
    Posts
    46


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi Al,
    Thank you very much for your advice. Will test.
    It is all about Tips & Tricks, so will learn step by step.
    Visual Basic was more friendly.
    Best Regards

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Here is an ASM code generator for delays.
    http://www.piclist.com/techref/picli...egen/delay.htm

    VB... May have been friendly but you were not working at the hardware level either...
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Dec 2008
    Location
    New York US
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Dear Al,
    So I tested your modified code and get result:
    Code:
     
    PORTB = % 10000001 '2 clock cycles x .2uSec =.4uSec
    @ goto $+1	   '2 clock cycles x .2uSec =.4uSec Skip next istr
    @goto $-1	   '2 clock cycles x .2uSec =.4uSec Return on prev address
    @nop  		   '3 clock cycles x.2uSec = .6uSec
    So total is equal 1.8uSEc what I really get
    Finally I come with decision to drop @nop
    So it looks now more affordable:
    PORTB = % 10000001 '2 clock cycles x .2uSec =.4uSec
    @ goto $+1	   '2 clock cycles x .2uSec =.4uSec Skip next istr
    @goto $-1	   '2 clock cycles x .2uSec =.4uSec Return on prev address
    Total is 1.2 uSec that is closer to what I espected.
    Thank you again for driving me in right direction.
    Best Regards

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    You are welcome.

    Al.
    All progress began with an idea

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