View Single Post
  #9   Spotlight this post!  
Unread 18-11-2003, 16:08
Andrew Andrew is offline
Registered User
#0356
 
Join Date: May 2002
Location: Little Rock, AR
Posts: 393
Andrew is a name known to allAndrew is a name known to allAndrew is a name known to allAndrew is a name known to allAndrew is a name known to allAndrew is a name known to all
Re: timing with user_routines_fast

Quote:
Originally posted by WizardOfAz
I don't think you can get any timing information by using user_routines_fast. If you look at the bottom of main.c, you see how this is used, and it doesn't help with knowing how much time has passed.


The other one (Process_Data_From_Local_IO) is called every time around the loop. How often this will happen depends on how much is being done in that function, and will also (every 17 or 26 ms) be delayed a different amount while
You're right. I didn't have the code in front of me. I was hoping when they said "every program cycle" that they were using strict terminology. However, that was too good to be true.

Another thought, if IFI has not snagged all timers, you could use one in a low-priority interrupt routine.

Based on page 10-5 of the "PICmicro 18C Reference Manual" timers 0,1, 2, and 3, tie into the low priority interrupt logic.

It should be straightforward to poll the timer registers and see if they're in use. Or look at INTCON and IPR registers to see if a high priority interrupt is located on one. If a timer is not in use, you should be able to use it to fire the low priority interrupt and run your timed cycle.

The good side of doing it this way is that low priority interrupt over-runs should not cause a crash in communications between your chip and the master uP.

Another way to do what you want would be to read a timer at the end of the main loop (assuming a timer is set in free-running mode). You can run your loop. Then, at the end of the loop you can poll the timer until it reaches your sample time. This is a clumsy way of doing things. However, if all four timers are in use (and I think at least three will be), this may be your only on chip option.