This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to use using "x"

Who can tell me the main usage of "using x" in interrupt service?

Parents
  • Assuming you are using C51:

    All main() loop (or background) functions use register bank 0 by default, let them. For all interrupts at a given priority set them to use register bank 1. If you have a standard 8051 with two interrupt priority levels you could use three register banks to reduce ISR vector latencies. For example, let all your normal function use register bank 0 (you don't need to specify using 0). Then, let's say you have a timer and the serial port at normal priority, define both of the ISR's with "using 1", and lastly if you had an external interrupt at high priority define its ISR with "using 2". E.g.

    int main(void)
    {
        /* I'm using reg. bank 0 */
        return 0;
    }
    
    void isrUart(void) interrupt UART_VECT using 1
    {
        /* I'm using reg. bank 1 but I am
        ** mutually exclusive to isrTimer0().
        */
    }
    
    void isrTimer0(void) interrupt TMR0_VECT using 1
    {
        /* I'm using reg. bank 1 but I am
        ** mutually exclusive to isrUart().
        */
    }
    
    void isrExt0(void) interrupt EXT0_VECT using 2
    {
        /* I'm using reg. bank 2 an I can
        ** interrupt both isrUart() and 
        ** isrTimer0().
        */
    }
    

    - Mark

Reply
  • Assuming you are using C51:

    All main() loop (or background) functions use register bank 0 by default, let them. For all interrupts at a given priority set them to use register bank 1. If you have a standard 8051 with two interrupt priority levels you could use three register banks to reduce ISR vector latencies. For example, let all your normal function use register bank 0 (you don't need to specify using 0). Then, let's say you have a timer and the serial port at normal priority, define both of the ISR's with "using 1", and lastly if you had an external interrupt at high priority define its ISR with "using 2". E.g.

    int main(void)
    {
        /* I'm using reg. bank 0 */
        return 0;
    }
    
    void isrUart(void) interrupt UART_VECT using 1
    {
        /* I'm using reg. bank 1 but I am
        ** mutually exclusive to isrTimer0().
        */
    }
    
    void isrTimer0(void) interrupt TMR0_VECT using 1
    {
        /* I'm using reg. bank 1 but I am
        ** mutually exclusive to isrUart().
        */
    }
    
    void isrExt0(void) interrupt EXT0_VECT using 2
    {
        /* I'm using reg. bank 2 an I can
        ** interrupt both isrUart() and 
        ** isrTimer0().
        */
    }
    

    - Mark

Children