Searching \ for '[SX] Exact timing with RTCC' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/sxints.htm?key=rtcc
Search entire site for: 'Exact timing with RTCC'.

Exact match. Not showing close matches.
PICList Thread
'[SX] Exact timing with RTCC'
2006\02\28@172541 by _djmn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, _djm wrote:

Hi,

I need to time a section of code on an SX52 exactly. I currently have something along the lines of :


clr RTCC

variable length code runs here

cjb RTCC, #159, $    want this to equal exactly 20320 cycles

I have the prescaler set at 1:256 so that there is no RTCC wrap around.

The problem with this is that because the timer is low res, I can't get the exact count and the cycles can fluctuate 256 up and down.

I was thinking of turning off the prescaler and triggerring an interrupt to increment a 16bit counter on the RTCC wrap around and then checking this.


Is this possible or is there a more elegant solution ?

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\28@184919 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

Time the code twice. Once with the prescaler set to 1:256 to get the MSB then run the same exact code with the prescaler set to 1:1 to get the LSB.

If the code IS exactly 20320 cycles then RTCC should be 79 during the 1:256 run, and RTCC should be 96 during the 1:1 run.

Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112344
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)


'[SX] Exact timing with RTCC'
2006\03\01@003949 by _djmn/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, _djm wrote:

In your example , the 79 x 256 = 20224 which I get but the problem I have is that the cjb RTCC, #79, $     could continue with anything from 20224 to 20479(20224 + 255) cycles depending on the code preceding it.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112389
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@040516 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

_djm,
 Okay, I misunderstood what you wanted.
 Since each cjb RTCC,#79,$ loop takes 6 cycles. I don't see how your going to get it to end on EXACTLY 20320.
 Can you post your code ? What is the mimimum and maximum cycles used by your "variable length code" ?

Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112396
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@050059 by _djmn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, _djm wrote:

I'm writing a video game and this variable code is the game logic which runs in the vsync. In the past I have used the RTCC and lived with the slight variances each frame but this has an effect on the picture. I'm now trying to get an exact number of cycles in this section each frame to improve the picture quality.

Even if I can't get exactly 20320 cycles, if I could get an exact figure below this then I could pad it out with a few nops after to get the delay I want. The problem is that depending on the amount of cycles the variable code (ie game logic) takes then I get a different delay (the range of the prescaler).

I've attached a simple example showing this.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112400
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@051134 by _djmn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, _djm wrote:

Just an additional note to this.

I can't make the variable code a deterministic number of cycles as at some points in the game there could be say 10 sprites on screen, at other times only 5.

I would therefore like to have this 20000 or so cycles to play around with knowing that the overall delay would be exactly the same no matter how much of it I used.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112401
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@053607 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

_djm,
 Okay now I understand. For my video modules the video generation is done completely by interrupts. So the "main" code doesn't have to worry about finishing in a certain amount of time.

 Andre' does something similar to what you need with the "XGameStation ME". The video code IS the main code and it calls a subroutine that does the "action", and when the subroutine returns, it waits for the next video frame time.

 If you goto www.xgamestation.com and download the video engine you should be able to see how he does it.

 Again, I much prefer to have the game code be the "main" and have the video generated completely by interrupts. But that's just me.

Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112406
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@054745 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

I just looked at the code for the XGameStation. He does exactly what you are proposing.
I guess the trick is to make sure that RTCC is less than 159 before you start looping. Then as soon as it hits 159 the loop will end.
The clock count could be off my as much as 6 cycles since that's how many cycles the loop takes.
Are you writing a game for the xgamestation ?
Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112411
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@062828 by _djmn/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, _djm wrote:

Yes I am. I am very familiar with the xgs demo code but they just live with the error.

I'll see if I can figure something out to make this more solid. It's a very minor change in the video picture but it's just annoying when you know it's there :)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112423
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@081625 by mebikeridern/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, mebikerider wrote:

Since 20320 = 635 x 32, would this work for your program?

Set the RTCC prescaler to divide by 32, set up to interrupt on RTCC rollover, and in the ISR, preset a 2-byte counter to 635, then decrement it each ISR.

When it hits zero, you've reached exactly 20320 counts. Reset the countdown counter to 635 then do your action.

This seems like it should repeat on an exact 20320 count interval.

David
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112450
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@083735 by _djmn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, _djm wrote:

Yes that's what I thought, this is what I mentioned in my original post. I'll give it a go. I just wondered if I'd missed an easy obvious solution.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112451
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@092947 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

Okay so now your checking a variable instead of RTCC. How are you going to make sure the variable has reached zero ?

Maybe like this:

 TEST counter
 JNZ $-1
Okay so let's say the counter is 1, and the interrupt occurs right after the TEST instruction. It's going to be another 7 cycles until you get out of the loop.

Now let's say the counter is 1 and the interrupt occurs right before the TEST instruction. It's going to be another 3 cycles until your out of the loop. So there will still be 4 cycles of "play".  Plus you have to figure in the cycles used for the interrupt call and return.

The problem is NOT setting a variable at the proper time. The problem is in the looping to wait for that variable.

You could just use RTCC and set it for -159 and wait for RTCC to reach zero the same way as your interrupt routine.

There may be a way around this, but I think an interrupt driven video generation method is best.
Interrupts are completely deterministic on the SX.

Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112466
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@131842 by mebikeridern/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, mebikerider wrote:

Bean, if you're referring to my solution, I was talking about using interrupts.

I don't know what action must be done every 20320 counts, but my idea was to do that action in the ISR. That way you would be repeating it exactly on the right count, not in user code where it would be subject to the variations of a test loop.

But of course, not knowing what that action is, I don't know if it can be done in the ISR.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112526
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\03\01@145830 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

David,
 Please don't take my comments as critizism of your method.

 If I understand he is using basically the code for the XGS ME tile engine, and that code doesn't use interrupt to generate the video.

 I think you and I are on the same page ;) using interrupts to generate the video.

Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=112331#m112542
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2006 , 2007 only
- Today
- New search...