Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12603 Discussions

Can't reset PIO edge capture using IOWR_ALTERA_AVALON_PIO_EDGE_CAP

Altera_Forum
Honored Contributor II
2,919 Views

Dear experts, 

 

I am Nios beginner. I wonder why I cannot reset the edge capture register using IOWR_ALTERA_AVALON_PIO_EDGE_CAP (to reset it inside my ISR)?  

 

//after first interrupt, edge capture register became 1 and remain 1 no matter how many time I reset it using IOWR_ALTERA_AVALON_PIO_EDGE_CAP 

 

pio_cnt=IORD_ALTERA_AVALON_PIO_EDGE_CAP(PIO_BASE); 

alt_printf("pio_cnt= %x \n", pio_cnt); // pio_cnt=1 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP (PIO_BASE,0); //try to reset to zero 

 

pio_cnt=IORD_ALTERA_AVALON_PIO_EDGE_CAP(PIO_BASE); 

alt_printf("pio_cnt= %x \n", pio_cnt); // still pio_cnt=1 !!!! 

 

 

I configured my PIO as (Input, Synchronous Falling Edge capture, Enable bit-clearing for edge capture register, Generate IRQ with edge trigger) using SOPC builder 10.1.  

Your advice is highly appreciated. Thank you in advance. 

 

Skw
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
1,742 Views

Hi skw 

In order to reset the edge capture register you must write one to the bits you want to reset, not write zero into the register. 

Then, this line 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP (PIO_BASE,0); 

must be changed in  

IOWR_ALTERA_AVALON_PIO_EDGE_CAP (PIO_BASE, IRQ_BIT_MASK); 

For example, if your irq signal is connected to pio bit 5, you'll define IRQ_BIT_MASK = 0x40 

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
1,742 Views

Hi Cris72, 

 

Thanks a lot. My board worked after the change. 

 

Best regards, 

Skw
0 Kudos
Altera_Forum
Honored Contributor II
1,742 Views

That's incredible! The same code with the same error is generated by Nios II SBT for Eclipse in the count_binary sample, that writes:  

 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP (BUTTON_PIO_BASE,0); 

 

writting '0' instead '1'... I was one day looking for the error and debugging the program before coming to these fora, when I finally found the solution. 

 

Why the sample code is wrong? 

 

Additionally, I have problems writting the display with the code generated by the system... I will look again in the forum to see if this is due again to errors in it...  

 

Regards,  

Antonio
0 Kudos
Altera_Forum
Honored Contributor II
1,742 Views

If the option Enable bit-clearing for edge capture register is turned off, writing any value to 

the edgecapture register clears all bits in the register. Otherwise, writing a 1 to a particular bit 

in the register clears only that bit. 

https://www.alteraforum.com/forum/attachment.php?attachmentid=11355
0 Kudos
Reply