C program interrupt handle function (AN1.pdf)

View: New views
5 Messages — Rating Filter:   Alert me  

C program interrupt handle function (AN1.pdf)

by lsousa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jeremy,
How can i write a c program that will handle an interrupt coming from
a systemc hw module.
I am fresh in the sw world , but i would expect something like

..main executing
...interrupt event would call

void interrupt 5 (for example)
{
flag=1
return
}

..and then, the sw execution would return to the main..and the flag
could be used.

I was expecting to see something like that in uart_loop_intr.c.
I am i missing something here?
Many Thanks
Licinio
_______________________________________________
http://www.opencores.org/mailman/listinfo/openrisc

Re: C program interrupt handle function (AN1.pdf)

by Jeremy Bennett-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2009-03-06 at 03:34 +0100, licinios@... wrote:

> How can i write a c program that will handle an interrupt coming from
> a systemc hw module.
> I am fresh in the sw world , but i would expect something like
>
> ..main executing
> ...interrupt event would call
>
> void interrupt 5 (for example)
> {
> flag=1
> return
> }
>
> ..and then, the sw execution would return to the main..and the flag
> could be used.
>
> I was expecting to see something like that in uart_loop_intr.c.
> I am i missing something here?

Hi Licinio,

uart_loop_intr.c is a very simple program, that is only used to
demonstrate that the UART is generating interrupts by inspecting its
interrupt register. I don't set up an interrupt handler.

You will need to extend the bootloader in start.s in two ways. First the
reset code will need to configure the programmable interrupt controller.
This doesn't have to be in assembler - it could be in C, before the call
to _main. You will need to ensure it is configured to accept edge
triggered interrupts on the relevant port.

Secondly you will need to add an interrupt handler for the external
interrupt exception (location 0x800).

Documentation on how to do this is in chapter 6 (exception handling) and
chapter 13 (programmable interrupt controller) of the architecture
manual.

If you do write a good simple example, I'll be very happy to include it
in the next release of my application note.

HTH,


Jeremy

--
Tel:      +44 (1202) 416955
Cell:     +44 (7970) 676050
SkypeID: jeremybennett
Email:   jeremy.bennett@...
Web:     www.embecosm.com


_______________________________________________
http://www.opencores.org/mailman/listinfo/openrisc

Parent Message unknown Re: C program interrupt handle function (AN1.pdf)

by lsousa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok,
where should i  find start.s ?
in the or1ksim-0.3.0rc3 dir ?

----- Original Message -----
From: Jeremy Bennett<jeremy.bennett@e...>
To:
Date: Fri Mar  6 10:38:03 CET 2009
Subject: [openrisc] C program interrupt handle function (AN1.pdf)

> On Fri, 2009-03-06 at 03:34 +0100, licinios at gmail.com wrote:
>
> > How can i write a c program that will handle an interrupt
> coming from
> > a systemc hw module.
> > I am fresh in the sw world , but i would expect something like
> >
> > ..main executing
> > ...interrupt event would call
> >
> > void interrupt 5 (for example)
> > {
> > flag=1
> > return
> > }
> >
> > ..and then, the sw execution would return to the main..and the
> flag
> > could be used.
> >
> > I was expecting to see something like that in
> uart_loop_intr.c.
> > I am i missing something here?
> Hi Licinio,
> uart_loop_intr.c is a very simple program, that is only used to
> demonstrate that the UART is generating interrupts by inspecting
> its
> interrupt register. I don't set up an interrupt handler.
> You will need to extend the bootloader in start.s in two ways.
> First the
> reset code will need to configure the programmable interrupt
> controller.
> This doesn't have to be in assembler - it could be in C, before the
> call
> to _main. You will need to ensure it is configured to accept edge
> triggered interrupts on the relevant port.
> Secondly you will need to add an interrupt handler for the external
> interrupt exception (location 0x800).
> Documentation on how to do this is in chapter 6 (exception
> handling) and
> chapter 13 (programmable interrupt controller) of the architecture
> manual.
> If you do write a good simple example, I'll be very happy to
> include it
> in the next release of my application note.
> HTH,
> Jeremy
> --
> Tel: +44 (1202) 416955
> Cell: +44 (7970) 676050
> SkypeID: jeremybennett
> Email: jeremy.bennett at embecosm.com
> Web: www.embecosm.com
>
>
_______________________________________________
http://www.opencores.org/mailman/listinfo/openrisc

Parent Message unknown Re: C program interrupt handle function (AN1.pdf)

by lsousa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok,
where should i  find start.s ?
in the or1ksim-0.3.0rc3 dir ?

----- Original Message -----
From: Jeremy Bennett<jeremy.bennett@e...>
To:
Date: Fri Mar  6 10:38:03 CET 2009
Subject: [openrisc] C program interrupt handle function (AN1.pdf)

> On Fri, 2009-03-06 at 03:34 +0100, licinios at gmail.com wrote:
>
> > How can i write a c program that will handle an interrupt
> coming from
> > a systemc hw module.
> > I am fresh in the sw world , but i would expect something like
> >
> > ..main executing
> > ...interrupt event would call
> >
> > void interrupt 5 (for example)
> > {
> > flag=1
> > return
> > }
> >
> > ..and then, the sw execution would return to the main..and the
> flag
> > could be used.
> >
> > I was expecting to see something like that in
> uart_loop_intr.c.
> > I am i missing something here?
> Hi Licinio,
> uart_loop_intr.c is a very simple program, that is only used to
> demonstrate that the UART is generating interrupts by inspecting
> its
> interrupt register. I don't set up an interrupt handler.
> You will need to extend the bootloader in start.s in two ways.
> First the
> reset code will need to configure the programmable interrupt
> controller.
> This doesn't have to be in assembler - it could be in C, before the
> call
> to _main. You will need to ensure it is configured to accept edge
> triggered interrupts on the relevant port.
> Secondly you will need to add an interrupt handler for the external
> interrupt exception (location 0x800).
> Documentation on how to do this is in chapter 6 (exception
> handling) and
> chapter 13 (programmable interrupt controller) of the architecture
> manual.
> If you do write a good simple example, I'll be very happy to
> include it
> in the next release of my application note.
> HTH,
> Jeremy
> --
> Tel: +44 (1202) 416955
> Cell: +44 (7970) 676050
> SkypeID: jeremybennett
> Email: jeremy.bennett at embecosm.com
> Web: www.embecosm.com
>
>
_______________________________________________
http://www.opencores.org/mailman/listinfo/openrisc

Re: C program interrupt handle function (AN1.pdf)

by Jeremy Bennett-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2009-03-06 at 19:20 +0100, licinios@... wrote:
> Ok,
>
> where should i  find start.s ?
>
> in the or1ksim-0.3.0rc3 dir ?
>
Hi Licinio,

It should be in the same directory as the uart_loop_intr.c. It's code
you link to your program that will run on Or1ksim. If you look at the
Makefile, you'll see how they link together.

HTH,


Jeremy

--
Tel:      +44 (1202) 416955
Cell:     +44 (7970) 676050
SkypeID: jeremybennett
Email:   jeremy.bennett@...
Web:     www.embecosm.com


_______________________________________________
http://www.opencores.org/mailman/listinfo/openrisc