Hallo,
wie im Titel herauszulesen ist, habe ich einen Interrupt Problem. Meine
vorgehensweise im Projekt war folgende:
Vorerst habe ich in ISE (VHDL) meine Hardware programmiert, funkioniert
auch super. Anschließend habe ich in XPS ein neues Projekt kreiert und
eine neue IP erzeugt. Die erzeugte IP habe ich mit meinen in ISE
entwickelten Code erweitert und habe so letztendlich die fertige IP in
XPS importiert und hinzugefügt. Nach dem ganzen vergeben der Ports und
Adressen und dem zusammenverknüpfen habe ich meine ersten Tests in der
SDK-Umgebung in C ausgeführt.
Nun will ich einen Interrupt von einem GPIO verwenden. Dafür habe ich in
XPS ein GPIO mit Interrupt hinzugefügt (nur Input und 1
Signal(Width=1)). An diesem GPIO habe ich aus meiner importierten IP
(von mir entwickelte IP) verbunden. Anscließend habe ich den Interrupt
ausgang des GPIOs auf den einem Interrupt-Controller angeschlossen und
letztendlich noch den Intr-Cnt. an dem Non-Ctritical-Intr.Eingang des
PPCs (PPC 440).
Soweit so gut, nun habe ich auf der SDK-Umgebung den Interrupt
programmiert. Der Interrupt an sich funktioniert prima, doch warum auch
immer wird die while-Schleife in der main nicht aufgerufen, sodass
zyklisch ein Interrupt gemacht wird. Dies habe im Debug-Modus geprüft,
indem ich einen Breakpoint auf die while-Schleife und eine weitere auf
"IntrFlag = 1" gesetzt habe. Die Interrupt-Flag wird 1 gesetzt, doch die
while schleife wird nie aufgerufen.
Die Frage zu meinem Problem ist, warum wird die while-Schleife nicht
ausgeführt nach dem Interrupt.
hier der c-Code:
1 | /
|
2 | #include <stdio.h>
|
3 | #include "xparameters.h"
|
4 | #include "xil_cache.h"
|
5 | #include "xintc.h"
|
6 | #include "xintc_l.h"
|
7 | #include "xstatus.h"
|
8 | #include "xil_exception.h"
|
9 | #include "intc_header.h"
|
10 | #include "xbasic_types.h"
|
11 | #include "xgpio.h"
|
12 | #include "gpio_header.h"
|
13 | #include "xbasic_types.h"
|
14 | #include "gpio_header.h"
|
15 | #include "gpio_intr_header.h"
|
16 | #include "iic_header.h"
|
17 | #include "uartlite_header.h"
|
18 | #include "xsysace.h"
|
19 | #include "sysace_header.h"
|
20 | #include "xbasic_types.h"
|
21 | #include "xbram.h"
|
22 | #include "bram_header.h"
|
23 | #include "xexception_l.h"
|
24 | #include "xbasic_types.h"
|
25 | #include "xutil.h"
|
26 |
|
27 | #define INTC_DEVICE_ID XPAR_XPS_INTC_0_DEVICE_ID
|
28 | #define INTC_GPIO_INPUT_INTERRUPT_ID XPAR_INTC_0_GPIO_4_VEC_ID
|
29 | #define GPIO_INPUT_CHANNEL1 1
|
30 |
|
31 | /********************* Function Prototypes *************************/
|
32 | void GpioInputHandler(void *CallBackRef);
|
33 |
|
34 | /********************** Variable Definitions ************************/
|
35 | XIntc InterruptController; /* The instance of the Interrupt Controller*/
|
36 |
|
37 | XIntc Intc_GpioInput; /* The Instance of the Interrupt Controller Driver */
|
38 |
|
39 | static XGpio xps_gpio_ND_Gpio; /* The Instance of the GPIO Driver */
|
40 | volatile u32 IntrFlag; /* Interrupt Handler Flag */
|
41 |
|
42 | int main(void) {
|
43 |
|
44 | Xil_ICacheEnable();
|
45 | Xil_DCacheEnable();
|
46 |
|
47 | print("---Entering main---\n\r");
|
48 |
|
49 | XGpio_Initialize(&xps_gpio_ND_Gpio, GPIO_INPUT_DEVICE_ID);
|
50 |
|
51 | XIntc_Initialize(&InterruptController, INTC_DEVICE_ID);
|
52 |
|
53 | XIntc_Connect(&InterruptController, XPAR_XPS_INTC_0_XPS_GPIO_ND_IP2INTC_IRPT_INTR, (XInterruptHandler)GpioInputHandler, (void *) (&xps_gpio_ND_Gpio));
|
54 |
|
55 | XGpio_InterruptEnable(&xps_gpio_ND_Gpio, GPIO_INPUT_CHANNEL1);
|
56 | XGpio_InterruptGlobalEnable(&xps_gpio_ND_Gpio);
|
57 | XIntc_Enable(&InterruptController, XPAR_XPS_INTC_0_XPS_GPIO_ND_IP2INTC_IRPT_INTR);
|
58 | XIntc_Start(&InterruptController, XIN_REAL_MODE);
|
59 |
|
60 |
|
61 | Xil_ExceptionInit();
|
62 | Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XIntc_InterruptHandler, &InterruptController);
|
63 |
|
64 | Xil_ExceptionEnable();
|
65 |
|
66 | int count = 0;
|
67 | x = 0;
|
68 |
|
69 | IntrFlag = 0;
|
70 | while (1) {
|
71 | if (IntrFlag !=(u32) 0) {
|
72 | IntrFlag = 0;
|
73 | xil_printf("INERRUPT IntrFlag wurde gesetzt!");
|
74 | }
|
75 |
|
76 | }
|
77 |
|
78 | print("---Exiting main---\n\r");
|
79 |
|
80 | Xil_DCacheDisable();
|
81 | Xil_ICacheDisable();
|
82 |
|
83 | return 0;
|
84 | }
|
85 |
|
86 | void GpioInputHandler(void *CallbackRef)
|
87 | {
|
88 | XGpio *GpioPtr = (XGpio *)CallbackRef;
|
89 |
|
90 | IntrFlag = 1;
|
91 |
|
92 | xil_printf("INERRUPT");
|
93 |
|
94 | // Clear the Interrupt
|
95 | XGpio_InterruptClear(GpioPtr, GPIO_INPUT_CHANNEL1);
|
96 | }
|
Die system.mhs und system.ucf file vom XPS-Projekt, wo die
Portzuweisungen zu erkennen sind, sind im Anhang hinzugefügt.
Würde mich über jede Hilfe sehr freuen.
mfg Cihan