<div dir="ltr"><div>Ok i got it ! </div><div><br></div>thanks a lot for the help jan ! <div><br></div><div>Yaron .</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 23, 2017 at 6:02 PM, <span dir="ltr"><<a href="mailto:Jan.Sommer@dlr.de" target="_blank">Jan.Sommer@dlr.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> -----Original Message-----<br>
> From: yaron o [mailto:<a href="mailto:jaron0123@gmail.com">jaron0123@gmail.com</a>]<br>
> Sent: Monday, October 23, 2017 4:17 PM<br>
> To: Sommer, Jan<br>
> Cc: <a href="mailto:users@rtems.org">users@rtems.org</a><br>
> Subject: Re: interrupt example leon3<br>
><br>
> Ok thank you ,<br>
><br>
> i succeeded to implement the interrupt on leon 3 ,thats what i added if some<br>
> one want to update the rtems-irq.c in sample file and add also:<br>
> ...<br>
> ...<br>
> #elif defined(LEON3)<br>
> *(unsigned long *) (0x80000240) = 0xc; // for leon 3<br>
> *(unsigned long *) (0x80000208) = 0xc; // for leon 3<br>
> #endif<br>
> ...<br>
> ...<br>
> in edition the printk instead of printf works for me either!<br>
><br>
><br>
> but still something missing for me and if some have an enswre it will be great ,<br>
> the question is why 0xc ?<br>
> i cant find anything that relate to the 0x12 (rtems_vector_number in<br>
> the rtems_interrupt_catch ).<br>
<br>
</span>That's what I meant with the hint in my previous email.<br>
If you set the interrupt mask register to 0xC you set the interrupt #2 and #3.<br>
In the gr712rc manual that would mean the APBUART and the interrupt for the GPIO as described in table 2.<br>
The interrupt ids used in RTEMS seem to be in accordance to the SparcV8 standard (table 7-1), i.e. they start with 0x11 for interrupt level 1.<br>
That's why if you want to capture interrupt #2 and #3 from the gr712rc manual you have to pass the ids 0x12 and 0x13 respectively.<br>
Interrupt ids from 0x00 to 0x10 are reserved for the standardized sparc traps.<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> thanks again to all<br>
> Yaron<br>
><br>
><br>
> On Mon, Oct 23, 2017 at 12:29 PM, <<a href="mailto:Jan.Sommer@dlr.de">Jan.Sommer@dlr.de</a>> wrote:<br>
> Hi Yaron,<br>
><br>
> > -----Original Message-----<br>
> > From: users [mailto:<a href="mailto:users-bounces@rtems.org">users-bounces@rtems.<wbr>org</a>] On Behalf Of yaron o<br>
> > Sent: Monday, October 23, 2017 10:21 AM<br>
> > To: <a href="mailto:users@rtems.org">users@rtems.org</a><br>
> > Subject: interrupt example leon3<br>
> ><br>
> > Hello all<br>
> ><br>
> > I want to add a new interrupt in my program , i check the rtems sample folder<br>
> in<br>
> > order to see how to add one ,i found the rtems-irq.c file and i did as the file<br>
> says<br>
> > but im using a leon 3 and theirs it says: error Example not intended for LEON3<br>
> > CPU.<br>
> > my question's are:<br>
> > firs how to call an interrupt in leon3 after i put it inside the ISR table, (i know<br>
> that<br>
> > in some OS you just write asm {INT #} in order to invoke the interrupt).<br>
> ><br>
><br>
> In rtems the low level interrupts are handled by the OS and forwarded to the<br>
> function you<br>
> registered with rtems_interrupt_catch.<br>
><br>
> > second i need some explain for the lines :<br>
> > *(unsigned long *) (0x80000090) = 0xc;<br>
> ><br>
> > *(unsigned long *) (0x80000098) = 0xc;<br>
> ><br>
><br>
> Checking the processor manual of the Leon2 these appear to be the registers of<br>
> the interrupt controller (interrupt mask and interrupt force register).<br>
> You might have to setup the interrupt controller of your Leon3 in a similar<br>
> manner for the example to work.<br>
><br>
> > in code below because i don't quit understand it ( maybe it's invoke the<br>
> interrupt<br>
> > but how does it relate to the handleExternalIrq) .<br>
> ><br>
><br>
> As far as I see it first registers the function handleExternalIrq to the interrupts<br>
> with id 0x12 and 0x13 using rtems_interrupt_catch.<br>
> Then it enables those interrupts in the interrupt controller (write to<br>
> 0x80000090).<br>
> Finally it triggers the interrupts by writing to the interrupt force register<br>
> (0x80000098).<br>
> The interrupt should occur, being noticed by rtems and the handleExternalIrq-<br>
> function should be called to handle the interrupt.<br>
> I had some problems with calling printf from within ISRs. I would replace it with<br>
> printk just to be sure.<br>
><br>
> One hint regarding the Leon3: In the gr712rc user manual the interrupt numbers<br>
> defined there are mapped in RTEMS to ids starting with 0x10 + irq#.<br>
> Meaning e.g. the AHBSTAT interrupt (number #1) will have the id 0x11 in RTEMS<br>
> and so on.<br>
><br>
> Cheers,<br>
><br>
> Jan<br>
><br>
> > i add the rtems-irq.c bellow"<br>
> > ------------------------------<wbr>------------------------------<wbr>--------------<br>
> > #include <rtems.h><br>
> > /* configuration information */<br>
> ><br>
> > #define CONFIGURE_INIT<br>
> ><br>
> > #include <bsp.h> /* for device driver prototypes */<br>
> ><br>
> > rtems_task Init (rtems_task_argument argument); rtems_isr handleExternalIrq<br>
> > (rtems_vector_number vector);<br>
> ><br>
> > #define CONFIGURE_APPLICATION_NEEDS_<wbr>CONSOLE_DRIVER<br>
> > #define CONFIGURE_APPLICATION_NEEDS_<wbr>CLOCK_DRIVER<br>
> ><br>
> > #define CONFIGURE_MAXIMUM_TASKS 4<br>
> ><br>
> > #define CONFIGURE_RTEMS_INIT_TASKS_<wbr>TABLE<br>
> ><br>
> > #define CONFIGURE_EXTRA_TASK_STACKS (3 *<br>
> > RTEMS_MINIMUM_STACK_SIZE)<br>
> ><br>
> > #include <rtems/confdefs.h><br>
> ><br>
> > #include <stdlib.h><br>
> > #include <stdio.h><br>
> ><br>
> > rtems_task<br>
> > Init<br>
> > (<br>
> > rtems_task_argument argument<br>
> > )<br>
> > {<br>
> > rtems_status_code status;<br>
> > rtems_isr_entry old_handle;<br>
> ><br>
> > status = rtems_interrupt_catch (handleExternalIrq, 0x12, &old_handle);<br>
> > status = rtems_interrupt_catch (handleExternalIrq, 0x13, &old_handle);<br>
> ><br>
> > #ifdef __erc32__<br>
> > *(unsigned long *) (0x1f8004c) = 0x7ff0;<br>
> > *(unsigned long *) (0x1f800d0) = 0x80000;<br>
> > *(unsigned long *) (0x1f80054) = 0x0c;<br>
> > #elif defined(LEON2)<br>
> > *(unsigned long *) (0x80000090) = 0xc;<br>
> > *(unsigned long *) (0x80000098) = 0xc;<br>
> > #elif defined(LEON3) #error Example<br>
> > not intended for LEON3 CPU #endif<br>
> > exit(0);<br>
> > }<br>
> ><br>
> > rtems_isr<br>
> > handleExternalIrq<br>
> > (<br>
> > rtems_vector_number vector<br>
> > )<br>
> > {<br>
> > printf ("External interrupt received with vector 0x%x\n", vector); }<br>
> ><br>
> ><br>
> > ------------------------------<wbr>------------------------------<wbr>----<br>
> ><br>
> > thanks a lot for the helpers !<br>
> ><br>
> > Yaron .<br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > signature-<br>
> ><br>
> 1.gif<<a href="https://lh4.googleusercontent.com/MAmpk4C_PMWbT3zd0qdOSQrjc8Z10" rel="noreferrer" target="_blank">https://lh4.<wbr>googleusercontent.com/MAmpk4C_<wbr>PMWbT3zd0qdOSQrjc8Z10</a><br>
> > rviGbNXOwcwHaQsEZMoMiIycSLYS_<wbr>mSXnOqfEy2QkNLP1y-0gO-<br>
> > 6yHBGUZLK1jtiiU6IpMMOJT-<wbr>bAVizgbQcyOwKWpJ6DM5a1K9PnjXrk<wbr>v8><br>
><br>
><br>
><br>
><br>
> --<br>
><br>
><br>
><br>
><br>
><br>
><br>
</div></div><span class="im HOEnZb">> Yaron Oz<br>
> R&D Software developer<br>
><br>
</span><div class="HOEnZb"><div class="h5">> Asher Space Research Institute<br>
> Technion – Institute of Technology<br>
> Technion City, Haifa 32000, Israel<br>
><br>
><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><span><div dir="ltr" style="margin-left:0pt"><table style="border:none;border-collapse:collapse"><colgroup><col width="278"><col width="322"></colgroup><tbody><tr style="height:27px"><td colspan="2" style="border-left:solid #000000 0px;border-right:solid #000000 0px;border-bottom:solid #000000 0px;border-top:solid #000000 0px;vertical-align:top;padding:7px 7px 7px 7px"><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt"><span style="font-size:13.333333333333332px;font-family:'Courier New';color:rgb(34,139,34);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap"><img src="https://lh4.googleusercontent.com/MAmpk4C_PMWbT3zd0qdOSQrjc8Z10rviGbNXOwcwHaQsEZMoMiIycSLYS_mSXnOqfEy2QkNLP1y-0gO-6yHBGUZLK1jtiiU6IpMMOJT-bAVizgbQcyOwKWpJ6DM5a1K9PnjXrkv8" width="384" height="20" style="border:none" alt="signature-1.gif"></span></p></td></tr></tbody></table></div></span></div></div></div>
</div></div>