interrupt example leon3

Jan.Sommer at dlr.de Jan.Sommer at dlr.de
Mon Oct 23 15:02:24 UTC 2017


> -----Original Message-----
> From: yaron o [mailto:jaron0123 at gmail.com]
> Sent: Monday, October 23, 2017 4:17 PM
> To: Sommer, Jan
> Cc: users at rtems.org
> Subject: Re: interrupt example leon3
> 
> Ok thank you ,
> 
> i succeeded to implement the interrupt on leon 3 ,thats what i added if some
> one want to update the rtems-irq.c in sample file and add also:
> ...
> ...
> #elif defined(LEON3)
>     *(unsigned long *) (0x80000240) = 0xc; // for leon 3
>     *(unsigned long *) (0x80000208) = 0xc; // for leon 3
> #endif
> ...
> ...
> in edition the printk instead of printf works for me either!
> 
> 
> but still something missing for me and if some have an enswre it will be great ,
> the question is why 0xc ?
> i cant find anything that relate to the 0x12 (rtems_vector_number in
> the rtems_interrupt_catch ).

That's what I meant with the hint in my previous email.
If you set the interrupt mask register to 0xC you set the interrupt #2 and #3.
In the gr712rc manual that would mean the APBUART and the interrupt for the GPIO as described in table 2.
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.
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.
Interrupt ids from 0x00 to 0x10 are reserved for the standardized sparc traps.

> 
> thanks again to all
> Yaron
> 
> 
> On Mon, Oct 23, 2017 at 12:29 PM, <Jan.Sommer at dlr.de> wrote:
> Hi Yaron,
> 
> > -----Original Message-----
> > From: users [mailto:users-bounces at rtems.org] On Behalf Of yaron o
> > Sent: Monday, October 23, 2017 10:21 AM
> > To: users at rtems.org
> > Subject: interrupt example leon3
> >
> > Hello all
> >
> > I want to add a new interrupt in my program , i check the rtems sample folder
> in
> > order to see how to add one ,i found the rtems-irq.c file and i did as the file
> says
> > but im using a leon 3 and theirs it says: error Example not intended for LEON3
> > CPU.
> > my question's are:
> > firs how to call an interrupt in leon3 after i put it inside the ISR table, (i know
> that
> > in some OS you just write asm {INT #} in order to invoke the interrupt).
> >
> 
> In rtems the low level interrupts are handled by the OS and forwarded to the
> function you
> registered with rtems_interrupt_catch.
> 
> > second i need some explain for the lines :
> > *(unsigned long *) (0x80000090) = 0xc;
> >
> > *(unsigned long *) (0x80000098) = 0xc;
> >
> 
> Checking the processor manual of the Leon2 these appear to be the registers of
> the interrupt controller (interrupt mask and interrupt force register).
> You might have to setup the interrupt controller of your Leon3 in a similar
> manner for the example to work.
> 
> > in code below  because i don't quit understand it ( maybe it's invoke the
> interrupt
> > but how does it relate to the handleExternalIrq) .
> >
> 
> As far as I see it first registers the function handleExternalIrq to the interrupts
> with id 0x12 and 0x13 using rtems_interrupt_catch.
> Then it enables those interrupts in the interrupt controller (write to
> 0x80000090).
> Finally it triggers the interrupts by writing to the interrupt force register
> (0x80000098).
> The interrupt should occur, being noticed by rtems and the handleExternalIrq-
> function should be called to handle the interrupt.
> I had some problems with calling printf from within ISRs. I would replace it with
> printk just to be sure.
> 
> One hint regarding the Leon3: In the gr712rc user manual the interrupt numbers
> defined there are mapped in RTEMS to ids starting with 0x10 + irq#.
> Meaning e.g. the AHBSTAT interrupt (number #1) will have the id 0x11 in RTEMS
> and so on.
> 
> Cheers,
> 
>    Jan
> 
> > i add the rtems-irq.c bellow"
> > --------------------------------------------------------------------------
> > #include <rtems.h>
> > /* configuration information */
> >
> > #define CONFIGURE_INIT
> >
> > #include <bsp.h> /* for device driver prototypes */
> >
> > rtems_task Init (rtems_task_argument argument); rtems_isr handleExternalIrq
> > (rtems_vector_number vector);
> >
> > #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
> > #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> >
> > #define CONFIGURE_MAXIMUM_TASKS             4
> >
> > #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> >
> > #define CONFIGURE_EXTRA_TASK_STACKS         (3 *
> > RTEMS_MINIMUM_STACK_SIZE)
> >
> > #include <rtems/confdefs.h>
> >
> > #include <stdlib.h>
> > #include <stdio.h>
> >
> > rtems_task
> > Init
> > (
> >     rtems_task_argument argument
> > )
> > {
> >     rtems_status_code status;
> >     rtems_isr_entry old_handle;
> >
> >     status = rtems_interrupt_catch (handleExternalIrq, 0x12, &old_handle);
> >     status = rtems_interrupt_catch (handleExternalIrq, 0x13, &old_handle);
> >
> > #ifdef __erc32__
> >     *(unsigned long *) (0x1f8004c) = 0x7ff0;
> >     *(unsigned long *) (0x1f800d0) = 0x80000;
> >     *(unsigned long *) (0x1f80054) = 0x0c;
> > #elif defined(LEON2)
> >     *(unsigned long *) (0x80000090) = 0xc;
> >     *(unsigned long *) (0x80000098) = 0xc;
> > #elif defined(LEON3) #error Example
> > not intended for LEON3 CPU #endif
> >     exit(0);
> > }
> >
> > rtems_isr
> > handleExternalIrq
> > (
> >     rtems_vector_number vector
> > )
> > {
> >     printf ("External interrupt received with vector 0x%x\n", vector); }
> >
> >
> > ----------------------------------------------------------------
> >
> > thanks a lot for the helpers !
> >
> > Yaron .
> >
> >
> >
> > --
> >  signature-
> >
> 1.gif<https://lh4.googleusercontent.com/MAmpk4C_PMWbT3zd0qdOSQrjc8Z10
> > rviGbNXOwcwHaQsEZMoMiIycSLYS_mSXnOqfEy2QkNLP1y-0gO-
> > 6yHBGUZLK1jtiiU6IpMMOJT-bAVizgbQcyOwKWpJ6DM5a1K9PnjXrkv8>
> 
> 
> 
> 
> --
> 
> 
> 
> 
> 
> 
> Yaron Oz
> R&D Software developer
> 
> Asher Space Research Institute
> Technion – Institute of Technology
> Technion City, Haifa 32000, Israel
> 
> 



More information about the users mailing list