#57 Hook

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

How to hook interrupt vector ?

Regards.

Discussion

1 2 > >> (Page 1 of 2)
  • 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 ?

     
1 2 > >> (Page 1 of 2)