#57 Hook

closed
Maarten Brock
None
5
2007-01-09
2006-12-11
Anton
No

How to hook interrupt vector ?

Regards.

Discussion

  • Maarten Brock
    Maarten Brock
    2006-12-11

    Logged In: YES
    user_id=888171
    Originator: NO

    If you can provide this little information the only answer can be RTFM.

     
  • Maarten Brock
    Maarten Brock
    2006-12-11

    • status: open --> pending
     
  • Anton
    Anton
    2006-12-12

    • status: pending --> open
     
  • Anton
    Anton
    2006-12-12

    Logged In: YES
    user_id=1099099
    Originator: YES

    What is RTFM ?

     
  • Logged In: YES
    user_id=603650
    Originator: NO

    Google it! Something like: Read The 'Fantastic' Manual... or is it Fenomenal??? You can find the manual here:

    http://sdcc.sourceforge.net/

     
  • Anton
    Anton
    2006-12-12

    Logged In: YES
    user_id=1099099
    Originator: YES

    This is an example:

    void INT0_INTVECT (void) interrupt 0 using 1
    {
    // routines
    }

    the above interrupt function is on header file and it fixed,
    there is no way i can modified it.

    so i need to hook up interrupt vector address to my own.

    how do i do that ?

    I thought RTFM is Read The F***ing Manual :P

    Regards.

     
  • Maarten Brock
    Maarten Brock
    2006-12-12

    Logged In: YES
    user_id=888171
    Originator: NO

    Ok, I assume you're using SDCC for mcs51.

    Currently SDCC only generates interrupt vectors for ISR's that are known compiling function main(). So if you don't include this header file, but define your own ISR's they will be used instead.

    void main(void)
    {
    }

    void MyIsr(void) interrupt 0 using 1
    {
    ...
    }

    If you also need to call the original INT0_INTVECT from your ISR I recommend (inline) assembly.

    void MyIsr(void) interrupt 0; //leave this prototype near main

    void main(void)
    {
    }

    void INT0_INTVECT(void); //prototype for original ISR to jump to

    static void dummy(void) _naked
    {
    _asm
    _MyIsr:
    ...
    ljmp _INT0_INTVECT
    _endasm
    }

    Greets,
    Maarten

     
  • Anton
    Anton
    2006-12-13

    Logged In: YES
    user_id=1099099
    Originator: YES

    Marteens, it's not working

    #include "at89x52.h"

    #include <puppy.h>

    void MY_INTERRUPT (void) interrupt 0;

    void main (void)
    {
    EA = 1;
    }

    void INT0_INTVECT(void);

    static void dummy (void) _naked
    {
    _asm
    LJMP _INT0_INTVECT
    _endasm;
    }

    inside puppy.h

    void INT0_INTVECT(void) interrupt 0 using 1
    {
    EA = 0;
    P0 = 0xFF;
    EA = 1;
    }

    Error message:
    SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.6.1 #4376 (Sep 14 2006) (MINGW32)

    Compiling...
    D:/WorkDir/Mikro/KOMUNI~1/Fax/01/dog.c(5) : error 71: interrupt no '0' already has a service routine 'INT0_INTVECT'
    D:/WorkDir/Mikro/KOMUNI~1/Fax/01/dog.c(9) : error 103: code not generated for 'main' due to previous errors
    D:/WorkDir/Mikro/KOMUNI~1/Fax/01/dog.c(12) : error 91: extern definition for 'INT0_INTVECT' mismatches with declaration.
    D:/WorkDir/Mikro/KOMUNI~1/Fax/01/puppy.h(1) : error 177: previously defined here
    D:/WorkDir/Mikro/KOMUNI~1/Fax/01/dog.c(12) : error 71: interrupt no '0' already has a service routine 'INT0_INTVECT'
    D:/WorkDir/Mikro/KOMUNI~1/Fax/01/dog.c(18) : error 103: code not generated for 'dummy' due to previous errors

    Compile error! Output not generated.

     
  • Maarten Brock
    Maarten Brock
    2006-12-13

    Logged In: YES
    user_id=888171
    Originator: NO

    Of course it's not working.

    1) I said do not include the header file and you insist on doing otherwise. Remove it.
    2) What is MY_INTERRUPT and why is it there? Remove it.
    3) Why are you defining (implementing) functions in a header in the first place? That is very bad practice. Only put preprocessor macros, extern declarations of variables and function prototypes in header files. Create a second source file puppy.c and include puppy.h in it if you need.

    Maarten

     
  • Anton
    Anton
    2006-12-14

    Logged In: YES
    user_id=1099099
    Originator: YES

    Marteen,

    1. I must include the header file, cause it has specific routines..
    2. MY_INTERRUPT is interrupt service routine of my own
    3. I will not do it again :D, thanks.

    Any solution to this problem ?

     
  • Maarten Brock
    Maarten Brock
    2006-12-25

    Logged In: YES
    user_id=888171
    Originator: NO

    Anton,

    1) You don't need to include the header file. If it has "specific routines" you need, I hope you mean function prototypes or preprocessor macros. You can copy them into another header file and use that one instead. It's all about making sure that when the compiler starts compiling main() it knows nothing about the interrupt you do not want to use (INT0_VECT).
    2) You say MY_INTERRUPT is an ISR of your own, but you did not show it's implementation. What's worse you want it to handle interrupt 0 which is also handled by your other ISR INT0_INTVECT. One interrupt cannot be handled by two ISR's.
    3) I have no idea what you mean by this. What will you not do again?

    4) Inside INT0_INTVECT you disable and enable all interrupts. This is not a Z80, interrupts of the same priority are disabled automatically and reenabled after RETI.
    5) Your dummy function is useless. It's missing the label _MY_INTERRUPT::
    6) What exactly are you trying to achieve? Should the interrupt jump to your isr (MY_INTERRUPT) and then to the original (INT0_VECT) or just yours?

    I have no further solutions.

     
  • Maarten Brock
    Maarten Brock
    2006-12-25

    • assigned_to: nobody --> maartenbrock
    • status: open --> pending
     
  • Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
    • status: pending --> closed