Interrupt calling from HEW

Hello All,

 

My problem statement = How to call ISR function automatically when interrupt will get generated ( in HEW) ?

As per knowledge, In HEW, there is "intprg.c". This .c contains all the functions with interrupt name. 

and in "vecttbl.c" , there is a function pointer named "void (*INT_Vectors[])(void)". and this function body contains address of all the functions which are present in "intprg.c".

 

So, I have called my "CAN_Ch_1_TX_ISR()" in interrupt function present in ""intprg.c".

 

So I enabled all interrupts in code. but when interrupt is generated, "CAN_Ch_1_TX_ISR()" not gets called automatically?

 

Is there any HEW setting needed to do for this?

  • Hew is an IDE not the compiler it doesn't enable anything you do that in the source code which is compiled and run. How do you know the interrupt is generated? Chances are you have not correctly enabled the CAN peripheral. You don't say what processor you are using, or what compiler.
  • You cannot call an interrupt routine. Calling an interrupt routine from C code will crash the application.
    Interrupt functions are called by hardware when the interrupt cause is triggered.
    On interrupt entry the processor saves return address and processor status register to the stack.
    On a normal function call the processor saves only the return address to the stack.
    If you call an interrupt function from C code wrong data is saved to the stack, and the application crashes latest when it tries to exit from the interrupt routine.

    As Paul mentioned, it is probably a problem of enabling the interrupt. In addition to the enable bits for each interrupt cause there is also a general interrupt enable bit in the processor status register. Usually a compiler provides something like "__enable_interrupt()" to enable interrupts in the processor status register.
  • In reply to FrankL:

    Thank you Paul and FrankL.

    I am using Renesas c/c++ compiler.

    Its true that hardware automatically calls ISR function. But how hardware will detect which function to call as ISR for a particular interrupt?
  • Thank you Paul and FrankL.

    I am using Renesas c/c++ compiler.

    Its true that hardware automatically calls ISR function. But how hardware will detect which function to call as ISR for a particular interrupt?
  • In reply to apu:

    The compiler is for H8/SH/M16C/RX ?
    In the processor the interrupt request bits for the different peripheral functions are hard-wired to corresponding interrupt vector. If a specific interrupt request is triggered the interrupt controller checks if the interrupt is enabled. If so it reads the corresponding entry from the vector table.
    The device hardware manual shows which interrupt vector corresponds to which interrupt cause.
  • In reply to FrankL:

    Hi FranKl

    I am using SH compiler.
    In manual , they have given table which indicates which "interrupt" will get generated based on which "interrupt flag".

    as per that , I have unmasked corresponding Interrupt in hardware register.
    during debugging, its found that "interrupt flags" are getting updated.

    But my question is how does hardware detects which function to call based on interrupt?
    Do I need to connect my ISR_FUN() to corresponding vector address?
  • In reply to apu:

    Hi FranKL
    Thank you for your help.
    I have already checked HW manual. But will go through it again.
    But If you found my question or my understanding wrong, then plz correct me.
  • In reply to Paul Brown:

    Hi Paul

    "How do you know the interrupt is generated? " ==> While doing debugging on hardware, I checked all CAN related registers in window provided by HEW. There I saw that , ISR related flags were updating as per code and I have already unmasked that interrupt.
  • In reply to apu:

    You still haven't said what processor, assuming an RX family then there are multiple locations you need to access to get an interrupt working not just the peripheral, also the IR register in the peripheral does not mean it is generating an interrupt just that if it were enabled it would do. So you need to check the peripheral interrup enable bit and the Interrupt control unit for the peripheral

    Paul
  • In reply to apu:

    Which SH processor do you use?
    For example SH-2 and SH-2A processors have a hardware interrupt controller. This checks ALL interrupt requests after every instruction. If it finds an active interrupt AND interrupts are enabled it will trigger the interrupt routine.
    SH-4 or SH-4A do NOT have an interrupt controller. There ALL interrupts trigger the same interrupt handler. This has to determine what the interrupt cause is by software and call the interrupt routine.

  • I am using SH72531 processor.
  • In reply to Paul Brown:

    I am using sh2A processor.
    I have unmasked interrupt using IMR register of sh72531.
    And also set highest priority to interrupt using IPR register of "Interrupt controller"
    sh72531 has HW interrupt controller
  • In reply to FrankL:

    I am using sh2A processor.
    I have unmasked interrupt using IMR register of sh72531.
    And also set highest priority to interrupt using IPR register of "Interrupt controller"
    sh72531 has HW interrupt controller
  • In reply to apu:

    And you have changed the Interrupt Mask Level in bit 4-7 of PSR, preferably set to 0000?
  • In reply to FrankL:

    There is no such PSR register in sh72531.

    registers related to CAN inetrrupt and Interrupt controller are (from sh72531) =

    IMR = mask/unmask CAN tx/rx interrupts
    MBIMR = enable/disable Mailbox interrupt after tx/rx
    IPR28 = CAN interrupt priority status register