Altera_Forum
Honored Contributor
15 years agoPorting PIO C-code from ARM-7 to Nios II (SE1-board) + performance issue.
Hi all,
I'm having a try at the moment to port my C-code from the arm-7 mcu, LPC-P2148 to Nios II, SE1-board , Cyclon-II, EP2C20F484C7. The arm-none-eabi-gcc compiler was used for the ARM-7 MCU and the NIOSII Eclipse Platform , version 9.1 for the nios ii/e cpu. ( e CPU: Cost and licence is based ). More details can bei obtained from my homepage. A) Performance issue: ARM-7: 12MHz clock , running at 48 Mhz via PLL. Nios II/e 50MHz clock , running at 50 Mhz. Used code: ( shifting LED Demo ) void startup_leds(void); void delay(void);# include <stdio.h># include <system.h># include "altera_avalon_pio_regs.h" // void startup_leds(void) { short is; short count = 4; int laufled = 0x00000001; for (count = 0; count < 4; count++ ) { for (is = 0; is < 16; is++ ) { IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, laufled); // IOPIN1 = laufled<<16; // was ARM-Code delay(); // wait laufled = laufled <<1; } for (is = 0; is < 16; is++ ) { //IOPIN1 = laufled<<16; // was ARM-Code IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, laufled); delay(); // wait laufled = laufled >>1; } } } // void delay(void) { short int wait = 6000; // arm-7: 50000 for same speed. while (wait) { wait = wait -1; } } // int main(void) { short count = 0; int delay; printf(" Hello from Nios II \n\r"); startup_leds(); while(1) { startup_leds(); } return 0; } Result. the arm-7 runs about 7 times faster than the nios ii/e ! Is the reason based on the Nios II/e CPU ? Maybe something wrong configured via SOPC Builder? Is my C-code correct? IOPIN1 = laufled<<16; = ARM-7 code with additional 16 ASR ! Converted to : OWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, laufled); B) What is the recommendation reading Data from a PIO or test the condition from a single bits. For Example, I want to check the status of BIT-16. The ARM-7 C-code Statement if (!( IOPIN0 & 0x00010000 )) .... Nios II statement ? I was playing around with the IORDALTERA_AVALON_PIO_DATA(base) but without any success yet. Problem with SOPC Builder and PIO optional settings ? Everybody answer is welcome, Regards , Reinhard