Are you sure it is working well, because i am using your programme with just creating one single thread (led glow)but i am getting stuck after applying interrupt ,do youknow why,here is my programme,
# include <cyg/hal/io.h> // for IOWR and IORD# include <cyg/kernel/kapi.h>
unsigned char ledpio;
cyg_interrupt int_pio;
cyg_handle_t int_pio_handle;
static void ledglow(cyg_addrword_t data)
{
volatile char* a=0x2120890;//writing to the base of ledpio for 111 sequence
*a=0x7;
}
cyg_uint32 isr_pio( cyg_vector_t vector ,cyg_addrword_t data)
{
cyg_interrupt_mask(vector);
cyg_interrupt_acknowledge(vector);
IOWR(BUTTON_PIO_BASE , 3, 0x00); // Reset the edgecapture register
ledpio = 0x8; //
IOWR (LED_PIO_BASE , 0, ledpio);
return(CYG_ISR_HANDLED);
}
void dsr_pio( cyg_vector_t vector,cyg_ucount32 count,cyg_addrword_t data)
{
}
void cyg_user_start(void)
{# define STACK_SIZE 0x1000
static char stack[STACK_SIZE];
static cyg_thread thread_data;
static cyg_handle_t thread_handle;
cyg_thread_create(10,ledglow,0,"interrupt test",&stack[0],STACK_SIZE, &thread_handle,&thread_data);
cyg_thread_resume( thread_handle);
cyg_interrupt_create(BUTTON_PIO_IRQ, 99,0,&isr_pio,&dsr_pio,&int_pio_handle,&int_pio);
cyg_interrupt_attach(int_pio_handle);
cyg_interrupt_unmask( BUTTON_PIO_IRQ);
IOWR(BUTTON_PIO_BASE , 1, 0x0);// PIO in input
IOWR(BUTTON_PIO_BASE , 3, 0x00);// Reset the edgecapture register
IOWR(BUTTON_PIO_BASE , 2, 0x01);// unmask bit0 all other masked
}
--- Quote Start ---
originally posted by glecordier@Feb 6 2006, 06:31 AM
i use the interrupt with the button pio like that:
# include <cyg/hal/io.h> // for iowr and iord
unsigned char ledpio;
cyg_interrupt int_pio;
cyg_handle_t int_pio_handle;
cyg_uint32 isr_pio( cyg_vector_t vector,
cyg_addrword_t data){
ledpio = ledpio|1; //
iowr (led_pio_base , 0, ledpio);
cyg_interrupt_mask(vector);
cyg_interrupt_acknowledge(vector);
iowr(button_pio_base , 3, 0x00); // reset the edgecapture register
ledpio = ledpio&~1; //
iowr (led_pio_base , 0, ledpio);
return(cyg_isr_handled | cyg_isr_call_dsr);
}
void dsr_pio( cyg_vector_t vector,
cyg_ucount32 count,
cyg_addrword_t data){
ledpio = ledpio|2; //
iowr (led_pio_base , 0, ledpio);
cyg_interrupt_unmask(vector);
ledpio = ledpio&~2; //
iowr (led_pio_base , 0, ledpio);
}
void cyg_user_start(void)
{
cyg_thread_create(..);
cyg_thread_resume(..);
cyg_interrupt_create(
button_pio_irq, // in /include/cyg/hal/system.h
99,
55,
&isr_pio,
&dsr_pio,
&int_pio_handle,
&int_pio);
cyg_interrupt_attach(int_pio_handle);
cyg_interrupt_unmask( button_pio_irq);
iowr(button_pio_base , 1, 0x00);// pio in input
iowr(button_pio_base , 3, 0x00);// reset the edgecapture register
iowr(button_pio_base , 2, 0x01);// unmask bit0 all other masked
}
i use the altera demo board cyclone ep1c20f400
with the pio core descriped in chapter 7 of the nios ii processor reference handbook
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=12562)
--- quote end ---
--- Quote End ---