<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Alberto,</div><div>No. My suggestion is to use the rtems_interrupt_catch but then enable the interrupt as in the example .</div><div>-Jerry </div><div><br>On Apr 4, 2014, at 11:33, Alberto Parnaso <<a href="mailto:pafbat00@yahoo.es">pafbat00@yahoo.es</a>> wrote:<br><br></div><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div><span></span></div><div>Hi Jerry, thank you very much for your response. If I have understand correctly I may have to install the interrupt not with "rtems_interrupt_catch" but using "_CPU_ISR_install_raw_handler". Is that correct? I am out of work now but I will test it on Monday and come back with the results. Thanks indeed!</div><div><br></div><div>Alberto.<br></div> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <div class="hr" style="margin: 5px 0px; padding: 0px; border: 1px solid rgb(204, 204, 204); border-image: none; height: 0px; line-height: 0; font-size: 0px;" contenteditable="false" readonly="true"></div> <font face="Arial" size="2"> <b><span style="font-weight: bold;">De:</span></b> Needell Gerald <<a href="mailto:jerry.needell@unh.edu">jerry.needell@unh.edu</a>><br> <b><span style="font-weight: bold;">Para:</span></b> Alberto Parnaso <<a href="mailto:pafbat00@yahoo.es">pafbat00@yahoo.es</a>> <br><b><span style="font-weight: bold;">CC:</span></b> Jerry Needell <<a href="mailto:jerry.needell@unh.edu">jerry.needell@unh.edu</a>>; RTEMS Send User List <<a href="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a>> <br> <b><span style="font-weight: bold;">Enviado:</span></b> Viernes 4 de abril de 2014 16:25<br> <b><span style="font-weight: bold;">Asunto:</span></b> Re: Installing interrupts for a custom driver<br> </font> </div> <div class="y_msg_container"><br><div id="yiv7000799547"><div>Alberto,<div>This may not have been correct- Take a look at the <span style="font-family: Menlo; font-size: 11px;">c/src/lib/libbsp/sparc/leon3/startup/</span>setec.c function from the LEON3 BSP (RTEMS 4.9.2) - attached:</div><div>After calling
rtems_catch_interrupt the LEON3 interrupt is then enabled - I install my handlers as a type=1 RTEMS interrupt.</div><div><br clear="none"></div><div>I hope that helps</div><div>- Jerry</div><div><br clear="none"></div><div><div style="margin: 0px; font-family: Menlo; font-size: 11px;">/* set_vector</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> *</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * This routine installs an interrupt vector on the SPARC simulator.</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> *</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * INPUT PARAMETERS:</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * handler - interrupt handler entry point</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * vector - vector
number</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * type - 0 indicates raw hardware connect</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * 1 indicates RTEMS interrupt connect</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> *</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * OUTPUT PARAMETERS: NONE</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> *</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * RETURNS:</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * address of previous interrupt handler</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> *</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * COPYRIGHT (c)
1989-1998.</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * On-Line Applications Research Corporation (OAR).</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> *</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * The license and distribution terms for this file may be</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * found in the file LICENSE in this distribution or at</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * <a href="http://www.rtems.com/license/LICENSE" target="_blank" rel="nofollow" shape="rect">http://www.rtems.com/license/LICENSE</a>.</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> *</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * Ported to LEON implementation of the SPARC by On-Line Applications</div><div style="margin: 0px;
font-family: Menlo; font-size: 11px;"> * Research Corporation (OAR) under contract to the European Space </div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * Agency (ESA).</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> *</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * LEON modifications of respective RTEMS file: COPYRIGHT (c) 1995. </div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * European Space Agency.</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> *</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> * $Id: setvec.c,v 1.2 2006/01/09 10:41:21 ralf Exp $</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> */</div><div style="margin: 0px; font-family: Menlo; font-size: 11px; min-height: 13px;"><br clear="none"></div><div style="margin:
0px; font-family: Menlo; font-size: 11px;">#include <bsp.h></div><div style="margin: 0px; font-family: Menlo; font-size: 11px; min-height: 13px;"><br clear="none"></div><div style="margin: 0px; font-family: Menlo; font-size: 11px;">rtems_isr_entry set_vector( /* returns old vector */</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> rtems_isr_entry handler, /* isr routine */</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> rtems_vector_number vector, /* vector number */</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> int type
/* RTEMS or RAW intr */</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;">)</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;">{</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> rtems_isr_entry previous_isr;</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> uint32_t real_trap;</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> uint32_t source;</div><div style="margin: 0px; font-family: Menlo; font-size: 11px; min-height: 13px;"><br clear="none"></div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> if ( type )</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> rtems_interrupt_catch( handler, vector, &previous_isr );</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> else </div><div style="margin: 0px;
font-family: Menlo; font-size: 11px;"> _CPU_ISR_install_raw_handler( vector, handler, (void *)&previous_isr );</div><div style="margin: 0px; font-family: Menlo; font-size: 11px; min-height: 13px;"><br clear="none"></div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> real_trap = SPARC_REAL_TRAP_NUMBER( vector );</div><div style="margin: 0px; font-family: Menlo; font-size: 11px; min-height: 13px;"><br clear="none"></div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> if ( LEON_INT_TRAP( real_trap ) ) {</div><div style="margin: 0px; font-family: Menlo; font-size: 11px; min-height: 13px;"> <br class="yiv7000799547webkit-block-placeholder" clear="none"></div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> source = LEON_TRAP_SOURCE( real_trap );</div><div style="margin: 0px; font-family: Menlo; font-size: 11px; min-height: 13px;"><br clear="none"></div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> LEON_Clear_interrupt( source );</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> LEON_Unmask_interrupt( source );</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> }</div><div style="margin: 0px; font-family: Menlo; font-size: 11px; min-height: 13px;"><br clear="none"></div><div style="margin: 0px; font-family: Menlo; font-size: 11px;"> return previous_isr;</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;">}</div><div style="margin: 0px; font-family: Menlo; font-size: 11px; min-height: 13px;"><br clear="none"></div><div class="yiv7000799547yqt2981802680" id="yiv7000799547yqt21097"><div><div>On Apr 4, 2014, at 9:33 AM, Needell Gerald <<a href="mailto:jerry.needell@unh.edu" target="_blank" rel="nofollow" shape="rect" ymailto="mailto:jerry.needell@unh.edu">jerry.needell@unh.edu</a>> wrote:</div><br class="yiv7000799547Apple-interchange-newline" clear="none"><blockquote type="cite"></blockquote></div></div></div></div><div class="yiv7000799547yqt2981802680" id="yiv7000799547yqt79739"><div><div style="-ms-word-wrap: break-word;">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 clear="none"><div><div>On Apr 4, 2014, at 9:12 AM, Alberto Parnaso <<a href="mailto:pafbat00@yahoo.es" target="_blank" rel="nofollow" shape="rect" ymailto="mailto:pafbat00@yahoo.es">pafbat00@yahoo.es</a>> wrote:</div><br class="yiv7000799547Apple-interchange-newline" clear="none"><blockquote type="cite"><div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 10pt; background-color: rgb(255, 255, 255);"><div class="yiv7000799547"><div id="yiv7000799547"><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div class="yiv7000799547"><div id="yiv7000799547"><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div class="yiv7000799547"> <div class="yiv7000799547"><div id="yiv7000799547"><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);">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 clear="none"><br clear="none"><br clear="none"><div><<</div><div>grmon2> info sys<br clear="none"> cpu0 Aeroflex Gaisler LEON3 SPARC V8 Processor <br clear="none"> AHB Master
0<br clear="none"> ahbjtag0 Aeroflex Gaisler JTAG Debug Link <br clear="none"> AHB Master 1<br clear="none"> mctrl0 European Space Agency LEON2 Memory Controller <br clear="none"> AHB: 00000000 - 20000000<br clear="none"> AHB: 20000000 - 40000000<br clear="none"> AHB: 40000000 - 80000000<br clear="none">
APB: 80000000 -
80000100<br clear="none"> 32-bit prom @ 0x00000000<br clear="none"> 32-bit static ram: 2 * 512 kbyte @ 0x40000000<br clear="none"> apbmst0 Aeroflex Gaisler AHB/APB Bridge <br clear="none"> AHB: 80000000 - 80100000<br clear="none"> dsu0 Aeroflex Gaisler LEON3 Debug Support Unit <br clear="none"> AHB: 90000000 - A0000000<br clear="none">
CPU0: win 8, hwbp 2, V8 mul/div, lddel 1, GRFPU-lite<br clear="none">
stack pointer 0x400ffff0<br clear="none"> icache 1 * 4 kB, 32 B/line <br clear="none"> dcache 1 * 4 kB, 32 B/line <br clear="none"> uart0 Aeroflex Gaisler Generic UART <br clear="none"> APB: 80000100 - 80000200<br clear="none"> IRQ: 2<br clear="none"> Baudrate 38343<br clear="none"> irqmp0 Aeroflex Gaisler Multi-processor
Interrupt Ctrl. <br clear="none"> APB: 80000200 - 80000300<br clear="none"> gptimer0 Aeroflex Gaisler Modular Timer Unit <br clear="none"> APB: 80000300 - 80000400<br clear="none"> IRQ: 8<br clear="none"> 8-bit scalar, 2 * 32-bit timers, divisor 50<br clear="none"> uart1 Aeroflex Gaisler Generic UART <br clear="none"> APB: 80000900 - 80000A00<br clear="none">
IRQ: 3<br clear="none"> Baudrate 38343<br clear="none"> gpio0 Aeroflex Gaisler General Purpose I/O port <br clear="none"> APB: 80000B00 - 80000C00</div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;">>><br clear="none"></div><div><br clear="none"></div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;">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-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;"><br clear="none"></div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;"><<</div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;">#include <rtems.h><br clear="none"><br clear="none">rtems_task Init( rtems_task_argument argument); /* forward declaration needed */<br clear="none"><br clear="none">/* configuration information */<br clear="none">#define CONFIGURE_INIT<br clear="none">#include <bsp.h> /* for device driver prototypes
*/<br clear="none"><br clear="none"><br clear="none">#define
CONFIGURE_RTEMS_INIT_TASKS_TABLE<br clear="none">#define
CONFIGURE_MAXIMUM_TASKS 4<br clear="none">#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER<br clear="none">#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br clear="none">#include <rtems/confdefs.h><br clear="none"><br clear="none">#include <stdio.h><br clear="none">#include <stdlib.h><br clear="none"><br clear="none">#include <sys/types.h><br clear="none">#include <sys/stat.h><br clear="none">#include <unistd.h><br clear="none">#include <errno.h><br clear="none">#include <apbuart.h><br clear="none"><br clear="none">// Global Variable to check if Interrupt has been signaled.<br clear="none">unsigned char uc_intr_flag;<br clear="none"><br clear="none">// Interrupt handler for APBUART peripheral <br clear="none">void UARTInterruptHandler ()<br clear="none">{<br clear="none"> uc_intr_flag = 1;<br clear="none">}<br clear="none"><br clear="none">rtems_task Init (rtems_task_argument ignored)<br clear="none">{<br clear="none"><br clear="none"> int i;<br clear="none"> rtems_status_code ret_status;<br clear="none"> rtems_isr_entry old_handler;<br clear="none"> volatile int *apbuart1 =
(int*)0x80000900;<br clear="none"> volatile int aux;<br clear="none"><br clear="none"> // Reset Interrupt Flag<br clear="none"> uc_intr_flag = 0;<br clear="none"><br clear="none"> printf("APB UART TEST with Interrupts\n");<br clear="none"><br clear="none"> aux = apbuart1[1];<br clear="none"> printf("APBUART1 STATUS: 0x%08X\n", aux);<br clear="none"> aux = apbuart1[2];<br clear="none"> printf("APBUART1 CONTROL: 0x%08X\n", aux);<br clear="none"> <br clear="none"> // Install UARTInterruptHandler at vector number 3 <br clear="none"> ret_status = rtems_interrupt_catch(<br clear="none"> (rtems_isr_entry)UARTInterruptHandler,<br clear="none">
(rtems_vector_number)3,<br clear="none"> &old_handler);<br clear="none"> switch (ret_status)<br clear="none"> {<br clear="none">
case RTEMS_SUCCESSFUL :<br clear="none"> printf("rtems_interrupt_catch: OK. New Interrupt installed for IRQ 3 - APBUART 2.\n");<br clear="none"> break ;<br clear="none"><br clear="none"> case RTEMS_INVALID_NUMBER :<br clear="none"> printf("rtems_interrupt_catch: RTEMS_INVALID_NUMBER.\n");<br clear="none"> break ;<br clear="none"><br clear="none"> case RTEMS_INVALID_ADDRESS :<br clear="none"> printf("rtems_interrupt_catch: RTEMS_INVALID_ADDRESS.\n");<br clear="none">
break ;<br clear="none"><br clear="none"> default
:<br clear="none"> printf("rtems_interrupt_catch: Unknown error.\n");<br clear="none"> break ;<br clear="none"> }<br clear="none"><br clear="none"> // Tell uart hardware to initialize directly<br clear="none"> /* Enable receiver (with interrupts) & Transmitter */<br clear="none"> apbuart1[2] = APBUART_CTRL_RE | APBUART_CTRL_TE | APBUART_CTRL_RI;<br clear="none"> aux = apbuart1[1];<br clear="none"> printf("UART1 STATUS: 0x%02X\n", aux);<br clear="none"> aux = apbuart1[2];<br clear="none"> printf("UART1 CONTROL: 0x%08X\n", aux);<br clear="none"><br clear="none"> // Write a character though APBUART1 to test it<br clear="none"> apbuart1[0] =
0xD8;<br clear="none"><br clear="none"> while (1)<br clear="none"> { // Perform some active wait time<br clear="none"> for (i
= 2000000; i > 0; i--);<br clear="none"><br clear="none"> printf("Hello World\n");<br clear="none"> apbuart1[0] = 0xD8;<br clear="none"> // If interrupt received, read from APBUART<br clear="none"> if (uc_intr_flag == 1)<br clear="none"> {<br clear="none"> uc_intr_flag = 0;<br clear="none"> aux = apbuart1[0];<br clear="none"> printf("Interrupt received from UART: data = %X\n", aux);<br clear="none"> }<br clear="none"> }<br clear="none"><br clear="none"> exit (0);<br clear="none">}<br clear="none">>></div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;"><br clear="none"></div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;">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 clear="none"></div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;"><br clear="none"></div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;">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-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;"><br clear="none"></div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;">Thanks!</div><div style="font-family: HelveticaNeue, "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 13.33px; font-style: normal; background-color: transparent;">Alberto.<br clear="none"></div></div></div></div> </div>
</div></div></div></div></div></div><div><br clear="none"></div></div></div>_______________________________________________<br clear="none">rtems-users mailing list<br clear="none"><a href="mailto:rtems-users@rtems.org" target="_blank" rel="nofollow" shape="rect" ymailto="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a><br clear="none"><a href="http://www.rtems.org/mailman/listinfo/rtems-users" target="_blank" rel="nofollow" shape="rect">http://www.rtems.org/mailman/listinfo/rtems-users</a><br clear="none"></blockquote></div><br clear="none"></div></div><br clear="none"></div></div></div><br><br></div> </div> </div> </div></div></blockquote></body></html>