<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Alberto,<div>If I recall correctly, rtems_interrupt_catch  installs the new interrupt handler, but does not enable it. You will also need to call rtems_interrupt_enable.</div><div>Good luck!</div><div>Jerry</div><div><br><div><div>On Apr 4, 2014, at 9:12 AM, Alberto Parnaso <<a href="mailto:pafbat00@yahoo.es">pafbat00@yahoo.es</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><div class="" role="main" style=""><div id="yiv3370076218"><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><div class="" style=""><div id="yiv3370076218"><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><div class=""> <div class="" style=""><div id="yiv3370076218"><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;">Hi,
 I am newbie in RTEMS and I am trying to install an interrupt into the 
interrupt controller to be capable of using an APBUART peripheral within
 a LEON3 based embedded processor. I configure the system so driver 
manager configures at BSP Start the console and the timer. I do have two
 APBUART configured in the system and my intention is to use the first 
one with console/termios driver and the second one with my own driver. 
Here is a copy the output of "info sys" command:<br><br><br><div><<</div><div>grmon2> info sys<br>          cpu0          Aeroflex Gaisler  LEON3 SPARC V8 Processor    <br>                  AHB Master
 0<br>          ahbjtag0  Aeroflex Gaisler  JTAG Debug Link    <br>                      AHB Master 1<br>          mctrl0    European Space Agency  LEON2 Memory Controller    <br>                      AHB: 00000000 - 20000000<br>                      AHB: 20000000 - 40000000<br>                      AHB: 40000000 - 80000000<br>                      APB: 80000000 -
 80000100<br>                      32-bit prom @ 0x00000000<br>                      32-bit static ram: 2 * 512 kbyte @ 0x40000000<br>          apbmst0   Aeroflex Gaisler  AHB/APB Bridge    <br>                  AHB: 80000000 - 80100000<br>          dsu0      Aeroflex Gaisler  LEON3 Debug Support Unit    <br>                   AHB: 90000000 - A0000000<br>          CPU0:  win 8, hwbp 2, V8 mul/div, lddel 1, GRFPU-lite<br>   
               stack pointer 0x400ffff0<br>                          icache 1 * 4 kB, 32 B/line <br>                  dcache 1 * 4 kB, 32 B/line <br>          uart0        Aeroflex Gaisler  Generic UART    <br>                  APB: 80000100 - 80000200<br>                  IRQ: 2<br>                  Baudrate 38343<br>          irqmp0    Aeroflex Gaisler  Multi-processor
 Interrupt Ctrl.    <br>                  APB: 80000200 - 80000300<br>          gptimer0  Aeroflex Gaisler  Modular Timer Unit    <br>                  APB: 80000300 - 80000400<br>                  IRQ: 8<br>                  8-bit scalar, 2 * 32-bit timers, divisor 50<br>          uart1     Aeroflex Gaisler  Generic UART    <br>                  APB: 80000900 - 80000A00<br>                 
 IRQ: 3<br>                  Baudrate 38343<br>          gpio0     Aeroflex Gaisler  General Purpose I/O port    <br>                  APB: 80000B00 - 80000C00</div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">>><br></div><div><br></div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">I
 have wrote a testing app to check if both UARTs work and also to try to
 install a handler for RX on the second UART. Here is my code:</div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><<</div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">#include <rtems.h><br><br>rtems_task Init( rtems_task_argument argument);    /* forward declaration needed */<br><br>/* configuration information */<br>#define CONFIGURE_INIT<br>#include <bsp.h> /* for device driver prototypes */<br><br><br>#define
 CONFIGURE_RTEMS_INIT_TASKS_TABLE<br>#define
 CONFIGURE_MAXIMUM_TASKS             4<br>#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER<br>#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br>#include <rtems/confdefs.h><br><br>#include <stdio.h><br>#include <stdlib.h><br><br>#include <sys/types.h><br>#include <sys/stat.h><br>#include <unistd.h><br>#include <errno.h><br>#include <apbuart.h><br><br>// Global Variable to check if Interrupt has been signaled.<br>unsigned char uc_intr_flag;<br><br>// Interrupt handler for APBUART peripheral <br>void UARTInterruptHandler ()<br>{<br>    uc_intr_flag = 1;<br>}<br><br>rtems_task Init (rtems_task_argument ignored)<br>{<br><br>    int i;<br>    rtems_status_code ret_status;<br>    rtems_isr_entry old_handler;<br>    volatile int *apbuart1 =
 (int*)0x80000900;<br>    volatile int aux;<br><br>    // Reset Interrupt Flag<br>    uc_intr_flag = 0;<br><br>    printf("APB UART TEST with Interrupts\n");<br><br>    aux = apbuart1[1];<br>    printf("APBUART1 STATUS: 0x%08X\n", aux);<br>    aux = apbuart1[2];<br>    printf("APBUART1 CONTROL: 0x%08X\n", aux);<br>    <br>    // Install UARTInterruptHandler at vector number 3 <br>    ret_status = rtems_interrupt_catch(<br>            (rtems_isr_entry)UARTInterruptHandler,<br>            (rtems_vector_number)3,<br>            &old_handler);<br>    switch (ret_status)<br>    {<br>   
        case RTEMS_SUCCESSFUL :<br>              printf("rtems_interrupt_catch: OK. New Interrupt installed for IRQ 3 - APBUART 2.\n");<br>          break ;<br><br>           case RTEMS_INVALID_NUMBER :<br>              printf("rtems_interrupt_catch: RTEMS_INVALID_NUMBER.\n");<br>              break ;<br><br>           case RTEMS_INVALID_ADDRESS :<br>               printf("rtems_interrupt_catch: RTEMS_INVALID_ADDRESS.\n");<br>               break ;<br><br>        default
 :<br>              printf("rtems_interrupt_catch: Unknown error.\n");<br>              break ;<br>    }<br><br>    // Tell uart hardware to initialize directly<br>    /* Enable receiver (with interrupts) & Transmitter */<br>    apbuart1[2] = APBUART_CTRL_RE | APBUART_CTRL_TE | APBUART_CTRL_RI;<br>    aux = apbuart1[1];<br>    printf("UART1 STATUS: 0x%02X\n", aux);<br>    aux = apbuart1[2];<br>    printf("UART1 CONTROL: 0x%08X\n", aux);<br><br>    // Write a character though APBUART1 to test it<br>    apbuart1[0] = 0xD8;<br><br>    while (1)<br>    {       // Perform some active wait time<br>        for (i
 = 2000000; i > 0; i--);<br><br>        printf("Hello World\n");<br>        apbuart1[0] = 0xD8;<br>        // If interrupt received, read from APBUART<br>        if (uc_intr_flag == 1)<br>        {<br>            uc_intr_flag = 0;<br>            aux = apbuart1[0];<br>            printf("Interrupt received from UART: data = %X\n", aux);<br>        }<br>    }<br><br>    exit (0);<br>}<br>>></div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">First
 UART (ie. debug UART) works fine and output data through STDOUT 
properly. Data sent through second UART is received also by another 
external terminal, and in other test I have been capable of receiving 
too. However UARTInterruptHandler is never signaled, thus I guess I am 
missing something with the interrupt instalation. <br></div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">Could any one see anything missing in this code? I
 would very much appreciate some help. Any clue on how to properly use interrupts will help me a lot!</div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">Thanks!</div><div style="font-size: 13.3333px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">Alberto.<br></div></div></div></div>   </div> 
 </div></div></div></div></div></div><div><br></div></div></div>_______________________________________________<br>rtems-users mailing list<br><a href="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a><br>http://www.rtems.org/mailman/listinfo/rtems-users<br></blockquote></div><br></div></body></html>