FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
5930 Discussions

How to setup a time interrupt on de10 standard using C language

CAlex
New Contributor II
4,176 Views

Hi, I'm a rookie of the SoCFPGA and I wanted to use it to build a FSM in HPS.
I have already finished building the system design as "User Manu" said and get the hps_0.h header file out.
I built my system based on the GHRD, and added a timer(100ms) using the Altera IP.
Now I want to play with it,yet there are little information about a timer or an interrupt working on SOC.
The board I'm using is a DE10-standard board.
Could anyone show me where to start?
And it will be better if you can provide a document/example on how to play with the Altera IP on C.
Thank you for your help.

0 Kudos
36 Replies
JingyangTeh
Employee
2,912 Views

Hi


I did not personally tried out an interrupt example before.

I think the discussion here is what you are looking for:

https://community.intel.com/t5/Programmable-Devices/Cyclone-V-Interrupt-Handling/td-p/160759?profile.language=de


We could try it together and discuss it as we go along.


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
2,908 Views

Thanks for reply,I'll go through this

 

0 Kudos
JingyangTeh
Employee
2,894 Views

Hi 


Sorry to inform you that, I am taking annual leave next week.

Please expect some delay in my reply.


Thank you very much in advance!


Regards

Jingyang, Teh


0 Kudos
EBERLAZARE_I_Intel
2,857 Views

Hi,


Do you have any update from your side?


0 Kudos
CAlex
New Contributor II
2,832 Views

Hi, there

 

I linked the IRQ signal from the timer to the HPS and mmBridge like GHRD did to their button PIO ips. 

Downloaded and ran the fpga design on my board and it turns out worked well.

So I believe the hardware part is done for now.

 

The issue is on software, I tried to figure out how to request, call and disable an IRQ through C,and I finished reading through the MPU part in Cyclone V handbook and IP handbook for Altera.

 

It terns out to be little helpful.

 

Now I'm reading the .dts file from the GHRD and the following is the capture of the button ip.

 

Also I found some information on hps_0.h, it's a define of an irq id as figuer 2 discribed.

 

But other than that I don't know what to do next.

 

Here are my list of questions:

1. I uploaded the fpga design to my board through the JTAG port and worked well(I made the led blink), is that mean the hardware design is done?

 

2.On softwware design, what should I do next?

 

3.When I used the Altera IP, I usually don't know how to link the parts, for example: there is a timer ip,thimer------->mmBridge------>f2h_bridge ,and I linked it to the fpga_only bridge, but I don't know why I need to link to these bridges, do you guys have any explination doc or turtour resources for qsys?

 

that's all, thanks for your reply BTW.

 

reguards.

0 Kudos
CAlex
New Contributor II
2,807 Views

Hi

Another issue occurred:

I include the <alt_interrupt.h> and trying to make the file,

and the error information:Error: Thumb encoding does not support an immediate here -- `msr CPSR_c,#(0x12|0x80|0x40)' occurred.

I read the src code and that appears related to 

alt_int_fixup_irq_stack(uint32_t stack_irq) function
Yet I didn't call that function.
 

What's that error means and most importantly how can I fix that?

 

reguards.

0 Kudos
EBERLAZARE_I_Intel
2,770 Views

Hi,


Can you share the screenshot of the error where it is coming from?


0 Kudos
CAlex
New Contributor II
2,751 Views

Sure.

 

makefile.png

BTW, I put the alt_interrupt.c in my file so that only this .c file is linked.

0 Kudos
JingyangTeh
Employee
2,723 Views

Hi Alex


Could you share me the make file that you are using?

I could not find any info regarding the error message.

Are you able to compile and run a simple hello world application?


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
2,696 Views

Hi,

thank you for your reply.

The attached is the makefile I use.

And yes I can compile and run the application if I don't use any of <alt_interrupt.h> related libs.

 

Could please you tell me more about the FPGA IRQ to HPS?

I built the system of a timer(100ms with)-->Avalon mm bridge -->f2h lw bridge 

with the irq---(0)--->f2h IRQ so the irq should be 72 in GIC.

 

I wrote a C code to use mmap to map the timer through the avalon and tryed to control it with (pTimer +1)which is the register of (start,stop,cont,ITO)

 

I also put the .dtb file and .sof file into the board but now I'm get a little confused. Here is the questions I have:

1.  Do I need to do the preload settings for this change? or can I just change the FPGA fabric since I didn't change the HPS design.

2. Do I need to write the kernal module to make the IRQ registered?

3. How can I register the interrupts ?

4.What kind of environment do I need to use the hwlib for Altera soft IP and HPS hard core IP(I assume the <alt_interrupt.h>is a HPS hard core IP lib).

 

And thank you for kind help.

I appreciate that.

reguards.

 

 

 

0 Kudos
JingyangTeh
Employee
2,627 Views

Hi CAlex


Sorry for the late reply.

Could you change to line 10 of the make files to the line below:

CFLAGS = -g -Wall  -D$(ALT_DEVICE_FAMILY) --include-dir=$(HWLIBS_ROOT)/include/$(ALT_DEVICE_FAMILY)  --include-dir=$(HWLIBS_ROOT)/include/


For the F2H interrupt, all the interrupts for F2H0 starts from 72 and F2H1 starts from 104.

The number you see in platform designer will be the offset from the start number base on which F2H controller it is connected.

E.g.:

In the GHRD.

The interrupt number for the dipsw _pio will be (72 +0)

The interrupt number for the button_pio will be (72 +1)

The interrupt number for the jtag_uartwill be (72 +2)


I checked from my colleague there is no need to change the linux device tree or create a linux module for the interrupt.

The important thing is getting the interrupt number.

With the interrupt number you can register a callback to the interrupt number.


Regards

Jingyang, Teh




0 Kudos
CAlex
New Contributor II
2,618 Views

Hi,

Thank you for the reply,

I tried your suggestion and the makefile was changed as below:

CAlex_0-1678774824616.png

And the EDS gave me the error said unrecognize the command line option --include-dir=

 

reguards

 

0 Kudos
CAlex
New Contributor II
2,609 Views

And another question is : do I need to write a linux module that request and free an irq

0 Kudos
CAlex
New Contributor II
2,587 Views

Never mind, but how exatly use C program to call and register an IRQ

0 Kudos
JingyangTeh
Employee
2,510 Views

Hi Alex


In the c program, we will be using the Hwlibs.

It is a set a library for you to access the hardware using apis.

https://www.rocketboards.org/foswiki/Documentation/HWLib#SoC_Abstraction_Layer_40SoCAL_41


You could find the list of API and its description here:

https://www.rocketboards.org/foswiki/pub/Documentation/HWLib/hwlib_api.tar.gz


Once you have the hwlibs installed. You could refer to the example.

In the example you will need to include the related header files and you could access the hardware and register.

e.g.

#include "alt_interrupt.h"

#include "alt_timers.h"


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
2,499 Views

Hi,

Thank you for the help.

I was informed that Linux can't use alt_interrupt.h , it only serve the bare metal invironment.

 

Now I'm trying to learn how to get an irq server in Linux system.

 

Could you find any resources for the De10 board?

 

Any way, Thank you for the help again.

 

reguards

0 Kudos
JingyangTeh
Employee
2,476 Views

Hi Alex


Yes, you are right.

The HWlibs are for baremetal only.

Sorry for assuming you are working on baremetal.

For linux development you could include the linux kernel header

#include <linux/interrupt.h>


You could refer to the example project repo here:

https://github.com/altera-opensource/linux-refdesigns


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
2,472 Views

Hi,

Thank you very much,

I'll check that ASAP.

 

reguards.

0 Kudos
JingyangTeh
Employee
2,407 Views

Hi Alex


Any update on this case?


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
2,396 Views

Hi,

still trying to understand what happened in the kernel,  also I tried to make the KML but there are some part missing on my SD card. The Kernel source can't be found in /usr/src menu and now I'm trying to build another sdcard and hope the source code is in the path I hoped.

 

I'll update the case when I get some progress.

 

Thank you for your help.

 

reguards.

0 Kudos
Reply