PDA

View Full Version : Time mismatch in PAUSEUS



hardcore
- 31st March 2010, 20:33
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.

'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:o

mark_s
- 31st March 2010, 20:58
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

aratti
- 31st March 2010, 22:07
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)



@ goto $+1
@ goto $+1
@ nop


Al.

hardcore
- 1st April 2010, 00:49
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.:cool:
Best Regards

mackrackit
- 1st April 2010, 01:19
Here is an ASM code generator for delays.
http://www.piclist.com/techref/piclist/codegen/delay.htm

VB... May have been friendly but you were not working at the hardware level either...

hardcore
- 1st April 2010, 15:38
Dear Al,
So I tested your modified code and get result:


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
:rolleyes:

aratti
- 1st April 2010, 15:51
You are welcome.

Al.