Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   enable interrupt (http://www.chiefdelphi.com/forums/showthread.php?t=34495)

Dean 12-02-2005 14:27

enable interrupt
 
I am trying to use an encoder and want to use interrupts, but I cannot figure out how to enable them! :confused: How do you enable interrupts? I have it programmed, just not enabled! :o

AIBob 12-02-2005 14:37

Re: enable interrupt
 
You need to call "Initialize_Interrupts();"..
...which is called in user_routines.c under function "void User_Initialization (void)" (at least in my teams code it works there)

Ryan M. 13-02-2005 07:37

Re: enable interrupt
 
Quote:

Originally Posted by AIBob
You need to call "Initialize_Interrupts();"..
...which is called in user_routines.c under function "void User_Initialization (void)" (at least in my teams code it works there)

He's refering to Kevin Watson's interrupt code which is avialable at http://www.kevin.org/frc.

If you want to just turn on the interrupts without having to go through that, then you'll have something like this in User_Initialization() (Or somewhere are there. You just have to do this before the interrupts are on)
I just copied this from the function in Watson's code which was referred to earlier, with one change (in bold) which actually enables the interrupt. Kevin's code just sets it up.
Code:

TRISBbits.TRISB2 = 1;        // make sure the RB2/INT2 pin is configured as an input [108]
INTCON3bits.INT2IP = 0;        // 0: interrupt 1 is low priority (leave at 0 for IFI controllers) [91]
                        // 1: interrupt 1 is high priority
INTCON2bits.INTEDG2 = 0;// 0: trigger on the falling-edge [90]
                        // 1: trigger on the rising-edge
INTCON3bits.INT2IF = 0;        // 0: external interrupt 1 hasn't happened (set to 0 before enabling the interrupt) [91]
                        // 1: external interrupt 1 has happened
INTCON3bits.INT2IE = 1;        // 0: disable interrupt        1 [91]
                        // 1: enable interrupt 1

That enables the interrupt on digital input 1. To learn how to do the rest, I'd look at Mr. Watson's code and read this white paper.


All times are GMT -5. The time now is 03:55.

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