Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

JTAG UART read interrupt

Hey all,

I am using the NiosII processor on the CycloneIII dev board and would like to send simple commands (e.g. "S200" or "P") to the processor using the JTAG UART interface from Eclipse. I would like to use interrupts to read incoming data and put it into a ring buffer for processing. I have done this before but on a different hardware platform. The issue I'm having is that the interrupt fires immediately and persists. In other words, upon reset, the processor goes into interrupt mode and keeps calling my registered interrupt function.

I believe the code I'm using to set the interrupt for the JTAG UART up is correct, as it actually works, but it shouldn't keep calling it. Also, I checked the status register and the RI flag is set, even though I haven't sent anything from Eclipse's command line. For completeness sake I added the code below.

The question I'm having is: Can I use the JTAG UART simply for interrupt based receiving while being connected to Eclipse, similar to regular UART operation?

static struct JTAG_UART_REGS *JTAG_UART = (struct JTAG_UART_REGS *) (JTAG_UART_BASE | 0x80000000);
void UART_init(){
    union JTAG_UART_CONTROL_REG JTAG_UART_CONTROL;
    JTAG_UART_CONTROL.control = 0x0;
    JTAG_UART_CONTROL.RE = 1;
    JTAG_UART_CONTROL.WE = 0;
    JTAG_UART->control = JTAG_UART_CONTROL.control;
    //alt_ic_irq_enable(0,JTAG_UART_IRQ);
    alt_irq_register(JTAG_UART_IRQ,JTAG_UART, UART_ISR);
}
void UART_ISR(){
    printf("Interrupt");
}
struct and union definitions

struct JTAG_UART_REGS {
    REGISTER    data;
    REGISTER    control;
};
union JTAG_UART_DATA_REG {
    REGISTER    data;
    struct {
        char    DATA;
        BITS    RESERVED :7;
        BITS    RVALID :1;
        BITS    RAVAIL :16;
    };
};
union JTAG_UART_CONTROL_REG {
    REGISTER    control;
    struct {
        BITS    RE :1;
        BITS    WE :1;
        BITS    RESERVED1 :6;
        BITS    RI :1;
        BITS    WI :1;
        BITS    AC :1;
        BITS    RESERVED2 :5;
        BITS    WSPACE :16;
    };
};

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I had the same problem on both JTAG-UART and UART, but without interrupt, mine is a polling routine,

    it keeps getting random waves of ZEROs from the input even without any input from the hyper terminal.