我正在使用Eclipse为MAX10上的NIOS II实现编写C代码。我有两个Verilog模块可生成一个脉冲,一个在上升沿检测上,一个在下降沿检测上。我已经用示波器查看了这些脉冲,并且两个脉冲都只在设计用来检测的边缘产生一个脉冲。但是我将这些脉冲发送到NIOS上的两个PIO输入,它们在检测到这些脉冲的上升沿时都会生成IRQ。上升沿检测仅在上升沿产生中断,但是下降沿检测在下降与上升沿产生中断,即使它们以相同的方式在代码中初始化。有想法吗?
static void rise_edge_ISR( void * context)
{
adc_start(MODULAR_ADC_0_SEQUENCER_CSR_BASE);
RISES[edge_occured] = IORD_ALTERA_AVALON_PIO_DATA(RISE_EDGE_TIME_BASE);
edge_occured++;
//Acknowledge the IRQ : Clear the edgecapture register by writing to it
(individual bit setting is disabled so any write to the edge capture reg
clears it)
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(RISE_EDGE_DETECTION_BASE,
RISE_EDGE_DETECTION_BIT_CLEARING_EDGE_REGISTER);
}
static void fall_edge_ISR( void * context)
{
adc_start(MODULAR_ADC_0_SEQUENCER_CSR_BASE);
FALLS[fall_edge_occured] = IORD_ALTERA_AVALON_PIO_DATA(FALL_EDGE_TIME_BASE);
fall_edge_occured++;
//Acknowledge the IRQ : Clear the edgecapture register by writing to it
(individual bit setting is disabled so any write to the edge capture reg
clears it)
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(FALL_EDGE_DETECTION_BASE,
FALL_EDGE_DETECTION_BIT_CLEARING_EDGE_REGISTER);
}
在main()
alt_ic_isr_register(RISE_EDGE_DETECTION_IRQ_INTERRUPT_CONTROLLER_ID, //alt_u32 ic_id
RISE_EDGE_DETECTION_IRQ, //alt_u32 irq
rise_edge_ISR, //alt_isr_func isr
NULL,
NULL);
alt_ic_isr_register(FALL_EDGE_DETECTION_IRQ_INTERRUPT_CONTROLLER_ID, //alt_u32 ic_id
FALL_EDGE_DETECTION_IRQ, //alt_u32 irq
fall_edge_ISR, //alt_isr_func isr
NULL,
NULL);
//Setting interrupt mask register to 1 enables interrupts
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(RISE_EDGE_DETECTION_BASE,
RISE_EDGE_DETECTION_CAPTURE);
//Setting interrupt mask register to 1 enables interrupts
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(FALL_EDGE_DETECTION_BASE,
FALL_EDGE_DETECTION_CAPTURE);