Forum: FPGA, VHDL & Co. Microblaze UART Interrupt


von Sandy (Gast)


Lesenswert?

Liebe Kollegen!

Ich versuche seit 13 Stunden einen Interrupt auszulösen und scheitere 
kläglich.

Bitte helft mir, ich weis nicht mehr weiter (und der Caffee ist alle).
1
#include <stdio.h>
2
#include <math.h>
3
#include <xgpio.h>
4
#include <xparameters.h>
5
#include <xintc.h>
6
#include <xuartlite.h>
7
#include "platform.h"
8
#include "mb_interface.h"
9
10
11
XUartLite_Handler CallBackRef;
12
13
14
void print(char *str);
15
void RecvHandler(void *CallBackRef);
16
17
//void Random_ISR (void * CallbackRef);
18
19
int status;
20
21
XUartLite interrupt;
22
//XGpio interrupt;
23
XGpio pwm;
24
XGpio enable;
25
XIntc intc;
26
27
int main()
28
{
29
30
  status = XUartLite_Initialize(&interrupt, XPAR_RS232_UART_1_DEVICE_ID);
31
    if (status != XST_SUCCESS) {
32
      print("XUartLite crash\n\r");
33
    }
34
35
  //XGpio_Initialize(&interrupt, XPAR_RS232_UART_1_DEVICE_ID);
36
  XIntc_Initialize(&intc, XPAR_INTC_0_DEVICE_ID);
37
38
  XGpio_Initialize(&pwm, XPAR_PWM_GPIO_0_DEVICE_ID);
39
  XGpio_Initialize(&enable, XPAR_EN_GPIO_0_DEVICE_ID);
40
41
42
  //XUartLite_SetRecvHandler(&interrupt, RecvHandler, &interrupt);
43
  XIntc_Connect(&intc, XPAR_XPS_INTC_0_RS232_UART_1_INTERRUPT_INTR, (XInterruptHandler)RecvHandler, NULL);
44
  XIntc_Start(&intc, XIN_REAL_MODE);
45
  XIntc_Enable(&intc, XPAR_XPS_INTC_0_RS232_UART_1_INTERRUPT_INTR);
46
47
  XGpio_SetDataDirection(&pwm,1,0);
48
  XGpio_SetDataDirection(&enable,1,0);
49
50
  //microblaze_enable_interrupts();
51
52
    print("Ready\n\r");
53
54
    XUartLite_EnableInterrupt(&interrupt);
55
    //XGpio_InterruptGlobalEnable (&interrupt);
56
  //XGpio_InterruptEnable(&interrupt, XGPIO_IR_CH1_MASK);
57
    //microblaze_enable_interrupts();
58
59
    while (1)
60
    {
61
62
63
    }
64
65
}
66
67
//void Random_ISR(void *CallbackRef)
68
void RecvHandler(void *CallBackRef)
69
{
70
  print("RCV\n\r");
71
}

Das Programm läuft auf einem Virtex 6 Board.
Es bleibt immer in der while(1) und ignoriert meine Sendeversuche von 
HTerm.

DANKE!!!
Sandy

von hiall (Gast)


Lesenswert?

Frag doch mal die Rückgabewerte der anderen Funktionen auch ab 
vielleicht bricht eine ab

von Sandy (Gast)


Lesenswert?

Gute Idee!

Ich hab die XIntc_Start und Connect auch abgefragt.
Keine Fehler.

LG
Sandy

von Sandy (Gast)


Lesenswert?

Der Interrupt geht endlich ABER jetzt läuft das Proftramm ständig in die 
ISR. Ich kann die Interrupt Flag nicht mehr löschen!?!?!?!?!?!? HELP
1
#include <stdio.h>
2
#include <math.h>
3
#include <xgpio.h>
4
#include <xparameters.h>
5
#include <xintc.h>
6
#include <xuartlite.h>
7
#include <xuartlite_l.h>
8
#include "platform.h"
9
#include "mb_interface.h"
10
11
12
XUartLite_Handler CallBackRef;
13
14
15
void print(char *str);
16
void RecvHandler(void *CallBackRef);
17
//void RecvTestHandler(void *CallBackRef);
18
19
void Random_ISR (void * CallbackRef);
20
21
int status;
22
23
XUartLite interrupt;
24
//XGpio interrupt;
25
XGpio pwm;
26
XGpio enable;
27
XIntc intc;
28
29
int main()
30
{
31
32
  status = XUartLite_Initialize(&interrupt, XPAR_UARTLITE_0_DEVICE_ID);
33
  if (status != XST_SUCCESS) {
34
      print("XUartLite crash\n\r");
35
  }
36
37
  status = XUartLite_SelfTest(&interrupt);
38
  if (status != XST_SUCCESS) {
39
        print("XUartLite_SelfTest crash\n\r");
40
    }
41
  //XGpio_Initialize(&interrupt, XPAR_RS232_UART_1_DEVICE_ID);
42
  status = XIntc_Initialize(&intc, XPAR_INTC_0_DEVICE_ID);
43
  if (status != XST_SUCCESS) {
44
      print("XIntc_Initialize crash\n\r");
45
  }
46
47
  XGpio_Initialize(&pwm, XPAR_PWM_GPIO_0_DEVICE_ID);
48
  XGpio_Initialize(&enable, XPAR_EN_GPIO_0_DEVICE_ID);
49
50
51
  //XUartLite_SetRecvHandler(&interrupt, RecvHandler, &interrupt);
52
  status = XIntc_Connect(&intc, XPAR_XPS_INTC_0_RS232_UART_1_INTERRUPT_INTR, (XInterruptHandler)RecvHandler, (void *)&interrupt);
53
  if (status != XST_SUCCESS) {
54
      print("XIntc_Initialize crash\n\r");
55
  }
56
  status = XIntc_Start(&intc, XIN_REAL_MODE);
57
  if (status != XST_SUCCESS) {
58
      print("XIntc_Start crash\n\r");
59
  }
60
  XIntc_Enable(&intc, XPAR_XPS_INTC_0_RS232_UART_1_INTERRUPT_INTR);
61
62
  XGpio_SetDataDirection(&pwm,1,0);
63
  XGpio_SetDataDirection(&enable,1,0);
64
65
  microblaze_enable_interrupts();
66
67
    print("Ready\n\r");
68
69
    XUartLite_EnableInterrupt(&interrupt);
70
71
72
    //XUartLite_SetRecvHandler(&interrupt, RecvTestHandler, &interrupt);
73
74
    //XGpio_InterruptGlobalEnable (&interrupt);
75
  //XGpio_InterruptEnable(&interrupt, XGPIO_IR_CH1_MASK);
76
    //microblaze_enable_interrupts();
77
78
    while (1)
79
    {
80
      //printf("while(1)");
81
      //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR, 0xaa);
82
      //status = XUartLite_RecvByte(XPAR_RS232_UART_1_BASEADDR);
83
      //printf("RCV=%d\n\r",status);
84
85
    }
86
87
}
88
89
//void Random_ISR(void *CallbackRef)
90
void RecvHandler(void *CallBackRef)
91
{
92
  XIntc_Acknowledge(&intc, XPAR_XPS_INTC_0_RS232_UART_1_INTERRUPT_INTR);
93
  print("RCV\n\r");
94
  XUartLite_ResetFifos(&interrupt);
95
96
}

von Georg A. (georga)


Lesenswert?

Gibt das printf über dieselbe UART aus?

von Sandy (Gast)


Lesenswert?

Ich denke schon, ja. Um ehrlich zu sein hab ich mir darüber nie Gedanken 
gemacht.

von Sandy (Gast)


Lesenswert?

Cool, selber Code - nichts geändert und jetzt geht der Interrupt wieder 
nicht. Hab ich gestern nur Artefakte empfangen!?!?!?

von N. G. (newgeneration) Benutzerseite


Lesenswert?

trotzdem nach dem Fehler suchen.
sonst tritt der vllt. sporasisch auf, und dann hast du wieder keine 
Lösung

von Sandy (Gast)


Lesenswert?

Nein, es geht NICHT!
Ich hab nichts geändert und der Interrupt ignoriert mich.

von Sandy (Gast)


Lesenswert?

Aufgegeben!
Ich habe es ganz hässlich ohne Interrupt gemacht. Jetzt steht der 
Prozessor bis etwas über die Uart empfangen wird.
Ich hoffe den Code sieht keiner.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.