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

Generating interrupts in RTX51 Tiny applications

I am having problems generating serial port (RI and TI) interrupts in an application that I have.
I have two functions being running with Round Robin disabled. Both functions send signals to each other when the tasks need to switch.
I've gone through the threads, and tried to follow the instructions given when other people had similar problems, but none of that is working for me.
I am also using Timer 2 for Uart 0, and timer 1 for uart 1. Interrupt for both UARTs are enabled.
I can only set the priorities for both interrupts as high. I tried doing this but it didn't seem to help.

Any ideas, thoughts or suggestions?

Parents
  • You should not use identical function (putchar or printf) and identical variables and buffers of exchange for different tasks,


    It is necessary to use different functions putchar (puchar_to_uart_0, puchar_to_uart_1) for different UARTS.





    I modified SERIAL.C from example Traffic for Silabs C8051F12x with two UARTS:





    /******************************************************************************/
    /*                                                                            */
    /*       SERIAL.C:  Interrupt Controlled Serial Interface for RTX-51 tiny     */
    /*                                                                            */
    /******************************************************************************/
    /*                                                                            */
    /*       Modified for Silabs C8051F12x with two UARTs and SFR paging          */
    /*                                                                            */
    /*       Last changes: 10 November 2005                                       */
    /******************************************************************************/
    
    #include <include.h>
    
    #define CTRL_Q    0x11            /* Control+Q character code             */
    #define CTRL_S    0x13            /* Control+S character code             */
    #define DEL       0x7F
    #define BACKSPACE 0x08
    #define CR        0x0D
    #define LF        0x0A
    #define ESC       0x1B            /* ESCAPE character code                */
    
    #define  OLEN  32                 /* size of serial transmission buffer   */
    data uchar ostart_0;              /* transmission buffer start index      */
    data uchar oend_0;                /* transmission buffer end index        */
    data uchar ostart_1;              /* transmission buffer start index      */
    data uchar oend_1;                /* transmission buffer end index        */
    char idata outbuf_0[OLEN];        /* storage for transmission buffer      */
    char idata outbuf_1[OLEN];        /* storage for transmission buffer      */
    data uchar otask_0 = 0xff;        /* task number of output task           */
    data uchar otask_1 = 0xff;        /* task number of output task           */
    
    #define  ILEN  32                 /* size of serial receiving buffer      */
    data uchar istart_0;              /* receiving buffer start index         */
    data uchar iend_0;                /* receiving buffer end index           */
    data uchar istart_1;              /* receiving buffer start index         */
    data uchar iend_1;                /* receiving buffer end index           */
    char idata inbuf_0[ILEN];         /* storage for receiving buffer         */
    char idata inbuf_1[ILEN];         /* storage for receiving buffer         */
    data uchar itask_0 = 0xff;        /* task number of output task           */
    data uchar itask_1 = 0xff;        /* task number of output task           */
    
    bool sendfull_0;                  /* flag: marks transmit buffer full     */
    bool sendactive_0;                /* flag: marks transmitter active       */
    bool sendfull_1;                  /* flag: marks transmit buffer full     */
    bool sendactive_1;                /* flag: marks transmitter active       */
    
    bool put_to_uart_0;               /* redirector for putchar & printf      */
    
    
    //**************************************************************************
    // Function prototype
    //**************************************************************************
    
    void putchar_to_uart_0 (char c);       // send char to UART_0
    void putchar_to_uart_1 (char c);       // send char to UART_1
    char putchar (char c);                 // common puchar for printf
    void getline_0 (uchar *line, uchar n); // get line from UART_0
    void getline_1 (uchar *line, uchar n); // get line from UART_0
    
    

Reply
  • You should not use identical function (putchar or printf) and identical variables and buffers of exchange for different tasks,


    It is necessary to use different functions putchar (puchar_to_uart_0, puchar_to_uart_1) for different UARTS.





    I modified SERIAL.C from example Traffic for Silabs C8051F12x with two UARTS:





    /******************************************************************************/
    /*                                                                            */
    /*       SERIAL.C:  Interrupt Controlled Serial Interface for RTX-51 tiny     */
    /*                                                                            */
    /******************************************************************************/
    /*                                                                            */
    /*       Modified for Silabs C8051F12x with two UARTs and SFR paging          */
    /*                                                                            */
    /*       Last changes: 10 November 2005                                       */
    /******************************************************************************/
    
    #include <include.h>
    
    #define CTRL_Q    0x11            /* Control+Q character code             */
    #define CTRL_S    0x13            /* Control+S character code             */
    #define DEL       0x7F
    #define BACKSPACE 0x08
    #define CR        0x0D
    #define LF        0x0A
    #define ESC       0x1B            /* ESCAPE character code                */
    
    #define  OLEN  32                 /* size of serial transmission buffer   */
    data uchar ostart_0;              /* transmission buffer start index      */
    data uchar oend_0;                /* transmission buffer end index        */
    data uchar ostart_1;              /* transmission buffer start index      */
    data uchar oend_1;                /* transmission buffer end index        */
    char idata outbuf_0[OLEN];        /* storage for transmission buffer      */
    char idata outbuf_1[OLEN];        /* storage for transmission buffer      */
    data uchar otask_0 = 0xff;        /* task number of output task           */
    data uchar otask_1 = 0xff;        /* task number of output task           */
    
    #define  ILEN  32                 /* size of serial receiving buffer      */
    data uchar istart_0;              /* receiving buffer start index         */
    data uchar iend_0;                /* receiving buffer end index           */
    data uchar istart_1;              /* receiving buffer start index         */
    data uchar iend_1;                /* receiving buffer end index           */
    char idata inbuf_0[ILEN];         /* storage for receiving buffer         */
    char idata inbuf_1[ILEN];         /* storage for receiving buffer         */
    data uchar itask_0 = 0xff;        /* task number of output task           */
    data uchar itask_1 = 0xff;        /* task number of output task           */
    
    bool sendfull_0;                  /* flag: marks transmit buffer full     */
    bool sendactive_0;                /* flag: marks transmitter active       */
    bool sendfull_1;                  /* flag: marks transmit buffer full     */
    bool sendactive_1;                /* flag: marks transmitter active       */
    
    bool put_to_uart_0;               /* redirector for putchar & printf      */
    
    
    //**************************************************************************
    // Function prototype
    //**************************************************************************
    
    void putchar_to_uart_0 (char c);       // send char to UART_0
    void putchar_to_uart_1 (char c);       // send char to UART_1
    char putchar (char c);                 // common puchar for printf
    void getline_0 (uchar *line, uchar n); // get line from UART_0
    void getline_1 (uchar *line, uchar n); // get line from UART_0
    
    

Children
No data