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++

Can you help me

Altera_Forum
Honored Contributor II
1,223 Views

Can you help me view my routine and find the error? 

I post my routine here. 

# include "system.h"# include "altera_avalon_pio_regs.h"# include "alt_types.h"# include "altera_avalon_timer_regs.h" 

alt_u8 led = 0;  

static void timer_interrupts(void* context, alt_u32 id)  

{  

IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE, 0); 

 

if(led==7) led=0;  

else led=led+1;  

}  

 

int main ()  

{  

alt_irq_register(TIMER_IRQ, (void*) &led, timer_interrupts);  

 

(when finished buiding,An error present at above line) 

IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER_BASE, 0x20); 

IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER_BASE, 0xBE); 

IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_BASE, 7); 

while (1)  

{  

switch(led) 

case 0: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x01); 

case 1: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x02); 

case 2: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x04); 

case 3: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x08); 

case 4: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x10); 

case 5: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x20); 

case 6: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x40); 

case 7: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x80); 

default: IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0x01);  

}  

return 0; 

 

the error messege list at the console window is: 

make -s all  

Linking hello_led_0.elf... 

/cygdrive/d/tools/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: region Chip_Ram is full (hello_led_0.elf section .text). Region needs to be 2704 bytes larger. 

/cygdrive/d/tools/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: section .rodata [00002020 -> 0000206f] overlaps section .exceptions [00002020 -> 000021c7] 

/cygdrive/d/tools/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: section .rwdata [00002070 -> 00003a7b] overlaps section .exceptions [00002020 -> 000021c7] 

/cygdrive/d/tools/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: section .bss [00003a7c -> 00003c8f] overlaps section .text [000021c8 -> 00004a8f] 

collect2: ld returned 1 exit status 

make: *** [hello_led_0.elf] Error 1 

Build completed 

 

In addition, I 'm not very clear about the function  

alt_irq_register( alt_u32 id, 

void *context, 

void (* isr)(void *, alt_u32)) 

for the viod* context; could anybody give me a clear explanation 

 

Thanks very much
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
308 Views

Well my idea is, that your program is to big (the hal library makes it really big). First, try to reduce the program size by setting the optimize size compiler option. 

Provide more on chip memory. 

Actually there is project template "Hello world small" for small memory footprints. 

Or use sdram instead of on chip memory. 

 

maybe there are already some solutions in the forum... you try the search function.
0 Kudos
Reply