Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   EDU Interrupt and Timer Template Code (http://www.chiefdelphi.com/forums/showthread.php?t=23088)

Kevin Watson 12-12-2003 21:56

EDU Interrupt and Timer Template Code
 
To get the creative juices going for the coming build season, I've written some template code that will make the job of using interrupts and timers on the EDU controller much easier. It's somewhere around 800 lines of heavily annotated code that can be used alone or dropped into your own code. I've also re-written user_routines_fast.c to allow the use of all external and timer related interrupts. I'm also working on what I think are some cool demos using this code. If you have an idea on how to improve the code, find a bug or do something cool with it, leave a note here or e-mail me. Anyway, the zipped archive is located here. Have fun.

-Kevin

CyberWolf_22 13-12-2003 19:37

Re: EDU Interrupt and Timer Template Code
 
Thank you this code is very helpful.

Kevin Watson 14-12-2003 16:28

Re: EDU Interrupt and Timer Template Code
 
No problem. I'm glad you found it helpful.

-Kevin

Larry Barello 15-12-2003 13:01

Re: EDU Interrupt and Timer Template Code
 
I wrote a small quadrature encoder interface using RB4-7 (ifi interrupt 3-6) and ran across a problem that doesnt appear to be addressed in your code: If you call a subroutine from an interrupt handler, you need to save additional stuff. You can find this in the C compiler in section 2.9 (something) or on the quick reference card. You need to replace

#pragma interrupt InterruptHandlerLow

with

#pragma interruptlow InterruptHandlerLow save=section(".tmpdata")

For more info, see below:

http://www.chiefdelphi.com/forums/sh...91&postcount=4

Kevin Watson 15-12-2003 13:15

Re: EDU Interrupt and Timer Template Code
 
Hi Larry,

Thanks, I've had a few exchanges with folks about this via e-mail already and will make some changes to the code and do some testing this evening. It's strange in that I haven't had any problems with a couple of other applications that I've written lately. One, a motor controller, receives many hundreds of interrupts a second from an encoder, yet I've never had a problem (actually, while doing some testing, I found that I could handle a peak interrupt rate of just over 5,000 interrupts/sec and still see no wierdness).

-Kevin

Larry Barello 15-12-2003 13:24

Re: EDU Interrupt and Timer Template Code
 
Quote:

Originally Posted by Kevin Watson
Hi Larry,

Thanks, I've had a few exchanges with folks about this via e-mail already and will make some changes to the code and do some testing this evening. It's strange in that I haven't had any problems with a couple of other applications that I've written lately. One, a motor controller, receives many hundreds of interrupts a second from an encoder, yet I've never had a problem (actually, while doing some testing, I found that I could handle a peak interrupt rate of just over 5,000 interrupts/sec and still see no wierdness).

-Kevin

I admit I was being a bit agressive: I have a 1000 count wheel on a servo motor as my test. I estimated around 1200-1800 RPM which gives 80-120K interrupts a second.

Even with the fix, that interrupt rate crashes the EDU system. It seems that 10-20k/sec is about as fast as it can go. Which is good since a 2 segment wheel on the back of a Boch motor generates about 5k/sec at full speed.

Joe Ross 16-12-2003 09:47

Re: EDU Interrupt and Timer Template Code
 
Quote:

Originally Posted by Larry Barello
I admit I was being a bit agressive: I have a 1000 count wheel on a servo motor as my test. I estimated around 1200-1800 RPM which gives 80-120K interrupts a second.

Even with the fix, that interrupt rate crashes the EDU system. It seems that 10-20k/sec is about as fast as it can go. Which is good since a 2 segment wheel on the back of a Boch motor generates about 5k/sec at full speed.

100k interrupts a second is extremely fast for a 40mhz processor. That's only 400 cycles between interrupts. Considering the time to save registers, as well as the fact that IFI has higher priority interupts, I can easily see why you had problems.

Kevin Watson 17-12-2003 15:08

Re: EDU Interrupt and Timer Template Code
 
I've updated the template code to better handle low-priority interrupts.
It can be found here: http://kevin.org/frc.

-Kevin

Kevin Watson 22-12-2003 14:11

Re: EDU Interrupt and Timer Template Code
 
"The Lucas" found a bug in my code related to timers 3/4 (thanks, Dude), so if you're using the interrupt and timer code that I posted, you might want to download the updated version from here: http://kevin.org/frc.

-Kevin


All times are GMT -5. The time now is 00:34.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi