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

DE10-Nano Handling FPGA interrupts

Altera_Forum
Honored Contributor II
2,818 Views

Hello, 

 

I'm trying to find info on how to handle an IRQ from FPGA to HPS via f2h_irq0 Interrupt Receiver. 

For now I don't have a clue. I just found info on how to handle GPIO like KEY0 or KEY1 but they are mapped to the HPS region. 

 

I hope to capture edge interrupts from SW[4..0]. Maybe I can find somebody with experience with this here. 

 

Regards!
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
1,008 Views

 

--- Quote Start ---  

Hello, 

 

I'm trying to find info on how to handle an IRQ from FPGA to HPS via f2h_irq0 Interrupt Receiver. 

For now I don't have a clue. I just found info on how to handle GPIO like KEY0 or KEY1 but they are mapped to the HPS region. 

 

I hope to capture edge interrupts from SW[4..0]. Maybe I can find somebody with experience with this here. 

 

Regards! 

--- Quote End ---  

 

Hello. 

For baremetal application use hardware libs routines for interrupt control and ISR handler registration.
0 Kudos
Altera_Forum
Honored Contributor II
1,008 Views

Hey thanks ! 

 

I'm trying to catch interrupts under linux. I was reading the altera documentation for HWLIB and SoCAL APIs without success. 

This is a simple starting program with a strange error: 

 

#include <stdio.h> # include "hwlib.h" # include "alt_interrupt.h" int main() { ALT_STATUS_CODE status; status = alt_int_global_init(); if(status == ALT_E_SUCCESS) printf("exito..."); return 0; } 

 

I got this error: 

$ make build arm-linux-gnueabihf-gcc -g -Wall -Werror -ID:/intelFPGA/17.0/embedded/ip/altera/ hps/altera_hps/hwlib/include -ID:/intelFPGA/17.0/embedded/ip/altera/hps/altera_h ps/hwlib/include/soc_cv_av -Dsoc_cv_av -c main.c -o main.o arm-linux-gnueabihf-gcc -g -Wall -Werror main.o -o ledtest main.o: In function `main': C:\Users\nhasbun\Desktop\C/main.c:7: undefined reference to `alt_int_global_init ' collect2.exe: error: ld returned 1 exit status make: *** Error 1 

 

And I'm using this makefile (https://pastebin.com/zxwzybqf) that I got from Altera examples for this board. Not sure what the problem is, since the header is being read.
0 Kudos
Altera_Forum
Honored Contributor II
1,008 Views

It's very simple from a hardware standpoint. f2h_irq0 is a 32-bit input. Connect SW[4:0] to f2h_irq0[4:0] (or whichever 5 bits you want to use) and tie the remaining f2h_irq0 bits to logic 0 if you're not using them for other interrupt sources.

0 Kudos
Altera_Forum
Honored Contributor II
1,008 Views

Hey thanks!  

 

I should stated that I was working under linux!. I was reading the altera documentation for HWLIB and SoCAL APIs without success. 

This is a simple starting program with a strange error: 

 

#include <stdio.h> # include "hwlib.h" # include "alt_interrupt.h" int main() { ALT_STATUS_CODE status; status = alt_int_global_init(); if(status == ALT_E_SUCCESS) printf("exito..."); return 0; } 

 

I got this error: 

 

main.o: In function `main': C:\Users\nhasbun\Desktop\C/main.c:7: undefined reference to `alt_int_global_init 

 

I guess it's a linker problem on my makefile ?
0 Kudos
Altera_Forum
Honored Contributor II
1,008 Views

Ok, so I solved that error by copying the alt_interrupt.c file to folder and improving a little my makefile. 

 

But now I got this error: 

 

C:\Users\nhasbun\AppData\Local\Temp\ccJaPb6S.s: Assembler messages: C:\Users\nhasbun\AppData\Local\Temp\ccJaPb6S.s:91: Error: Thumb encoding does no t support an immediate here -- `msr CPSR_c,#(0x12|0x80|0x40)' make: *** Error 1 

 

This is my makefile: 

 

 

--- Quote Start ---  

TARGET = main 

 

#  

ALT_DEVICE_FAMILY ?= soc_cv_av 

HWLIBS_ROOT = $(SOCEDS_DEST_ROOT)/ip/altera/hps/altera_hps/hwlib 

 

#  

SRCS=$(wildcard *.c) $(wildcard */*.c) 

OBJECTS=$(SRCS:.c=.o) 

 

CFLAGS = -g -Wall -Werror  

-I$(HWLIBS_ROOT)/include  

-I$(HWLIBS_ROOT)/include/$(ALT_DEVICE_FAMILY)  

-D$(ALT_DEVICE_FAMILY) 

LDFLAGS = -g -Wall -Werror  

-pthread -lpthread -lm 

 

CROSS_COMPILE = arm-linux-gnueabihf- 

CC = $(CROSS_COMPILE)gcc 

LD = $(CROSS_COMPILE)gcc 

ARCH = arm 

 

.PHONY: build 

build: $(TARGET) 

 

$(TARGET): $(OBJECTS) 

$(LD) $(LDFLAGS) $^ -o $@ 

 

%.o : %.c $(HEADERS) 

$(CC) $(CFLAGS) -c $< -o $@ 

 

.PHONY: clean 

clean: 

rm -f $(TARGET) *.a *.o *~ 

rm -f $(UART_CORE_LIB_ROOT)/*.o 

 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
1,008 Views

Ok, so I solved that error by copying the alt_interrupt.c file to folder and improving a little my makefile. 

 

But now I got this error: 

 

C:\Users\nhasbun\AppData\Local\Temp\ccJaPb6S.s: Assembler messages: C:\Users\nhasbun\AppData\Local\Temp\ccJaPb6S.s:91: Error: Thumb encoding does no t support an immediate here -- `msr CPSR_c,#(0x12|0x80|0x40)' make: *** Error 1
0 Kudos
Altera_Forum
Honored Contributor II
1,008 Views

Hi! 

Are you solve the problem now? I happend to have the same problem, I copy the alt_interrupt.c file to my project folder and add command lines to my nmake, but it still dosen't work.The error like 

 

Thumb encoding does not support an immediate here -- `msr CPSR_c,#(0x12|0x80|0x40)'
0 Kudos
Altera_Forum
Honored Contributor II
1,008 Views

I just gave up. It seems like we had the libraries to use the FPGA interrupts under Linux but there is simply not enough info out there on how to make it work.

0 Kudos
Reply