PDA

View Full Version : Issue with Array causing PauseUS to have 16uS overhead



bcd
- 9th November 2007, 09:45
I have the following at the top of my code to initialise a 65 byte array to 0:
<code>
for x = 0 to 64
ch[x] = 0
next
</code>

This initialises my array to all 0 values. Problem is that any PauseUS I use after this have an overhead of 16uS, so a PauseUs 8 becomes 24uS.

If I comment out the For...Next loop then the time penalty goes, although I get crap in the array. I assume I must be crossing a code boundary or some such thing and this causes the extra overhead when bank switching occurs.

Any one have any idea ?? I don't really need my PauseUS to be accurate for this, but I am interested how a simple change could cause so much of a latency in another statement.

Any tips on optimisation ??

Using PBP2.47

Thanks,
Bill.

Acetronics2
- 9th November 2007, 12:47
Hi, Bill

Just a stupid basic line :

GOSUB Manual_pauseus_minimum_delay_section '...

Bet your osc is default 4Mhz ...

The only tip :

Insert

@ NOP
.
.
.
.
@ NOP

Alain

Darrel Taylor
- 9th November 2007, 21:08
The PAUSEUS statement has a minimum time it can delay.
It has to calculate what to do each use at Run-Time.

@ &nbsp;4Mhz, the delay is 24us

A "1us minimum" delay routine can be found here ...
http://www.picbasic.co.uk/forum/showthread.php?p=22098

Another possibility is corruption of the Pause command from using a Bootloader without ...
DEFINE LOADER_USED 1
( but, nobody ever admits to that one. :) )
<br>

bcd
- 9th November 2007, 21:23
The PIC is running at 20MHz. I have Define OSC 20 at the top of the code.
I am not using Interrupts. Its a simple State Machine loop that runs correctly without the For-Next loop that clears the array.

Without the For-Next loop the PauseUS has the correct time, but with it the PauseUS time is way off.

I tried using NOPs, but was still getting a long delay. I think it must an interaction between the for-next loop that clears the array and the HSEROUT.

I borrowed a DSO from work so I can do a bit of in depth investigation into what is happening and why.

I will post the code later when I have it to hand.

bill.

BrianT
- 9th November 2007, 23:20
I think CLEAR will zero all your variables without you needing the For..Next lines you now have.

HTH
Brian

Acetronics2
- 10th November 2007, 08:41
Hi, Bill

1) why not try to place your delay comp. just BEFORE the loop ??? ( could help for debugging too ... )

2) you can assign your variables banking ... see $ 7.3



Now, 16µS @ 20 MHz is ~ 60-80 assembler lines ... that make a lot of bank switchings ... if it is bank switching.

What's your processor ???

Alain