--- Quote Start ---
originally posted by lee@Jan 2 2007, 11:54 AM
i'm in the process of converting an old nios ii project over to ecos. the interrupts do not work when i use the ecos api. here is the relevant code.
#include <cyg/hal/system.h># include <cyg/kernel/kapi.h>
unsigned char abycin;
volatile unsigned int byrxptr = 0;
unsigned int bywrptr = 0;
cyg_uint32 uart_debug_isr(cyg_vector_t vector, cyg_addrword_t data)
{
volatile int clr_int;
// block this interrupt from occurring until this isr completes.
cyg_interrupt_mask(vector);
// tell the processor that we have received the interrupt.
cyg_interrupt_acknowledge(vector);
if (!(iord_altera_avalon_uart_status(uart_debug_base) & 0x02))
{
abycin = iord_altera_avalon_uart_rxdata(uart_debug_base);
if(byrxptr < (rxbuf_size_debug - 2)) byrxptr++;
else byrxptr = 0;
}
else clr_int = iord_altera_avalon_uart_rxdata(uart_debug_base); // read udr if framing error just to clear interrupt
// allow this interrupt to occur again.
//cyg_interrupt_unmask (vector);
// tell the kernel that chained interrupt processing is done.
//return cyg_isr_handled;
return cyg_isr_handled | cyg_isr_call_dsr;
}
void uart_debug_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
{
//printf("dsr\n");
//out_str("dsr\n");
cyg_interrupt_unmask(vector);
}
void out_str(char *s)
{
unsigned char *c;
for(c = s;; c++)
{
if(*c == 0)
break;
out_char((unsigned char)*c);
}
}
void out_char(unsigned char c)
{
while(!(iord_altera_avalon_uart_status(uart_debug_base) & 0x40));
iowr_altera_avalon_uart_txdata(uart_debug_base, c);
}
void cyg_user_start(void)
{
int divisor = 0;
int old = 0;
cyg_handle_t uart_debug_handle, timer_handle;
cyg_interrupt uart_debug_intr, timer_intr;
cyg_interrupt_create(uart_debug_irq, 99, 0, &uart_debug_isr, &uart_debug_dsr, &uart_debug_handle, &uart_debug_intr);
cyg_interrupt_attach(uart_debug_handle);
cyg_interrupt_disable();
/* other initialization tasks performed here */
cyg_interrupt_enable();
cyg_interrupt_unmask(uart_debug_irq);
while(1)
{
while (bywrptr != byrxptr) // check to see if any data has been received by the uart
{
printf("bywrptr != byrxptr\n");
processrxbuf(); // process new data received from uart
}
//while (rtdwrptr != rtdrxptr)
//mdp();
}
}
is there something special that needs to be done in the nios2configtool to get interrupts to work?
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=20322)</div> --- Quote End ---
You're probably suffering from the fact that the eCos port already contains a driver for the UART and two drivers talking to one piece of hardware is never good