先转个好文章~~~

 http://edacn.net/?227035

altera de2板 ,quartus II 9.0,niso II 9.0 ide,

1 c程序

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

int main (void) __attribute__ ((weak, alias ("alt_main")));

int alt_main (void)
{
  alt_u8 led = 0x2;
  alt_u8 dir = 0;
  volatile int i;
  while (1)
  {
    if (led & 0x81)
    {
      dir = (dir ^ 0x1);
    }

    if (dir)
    {
      led = led >> 1;
    }
    else
    {
      led = led << 1;
    }
    IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led);

    i = 0;
    while (i<200000)
      i++;
  }

  return 0;
}

二  问题

1Error: Generation skipped because the system has validation errors.

原因:

没有指定CPUreset vectorexception vector

解决方法:

双击CPU,在Core Nios2标签中指定reset vectorexception vector,由于程序很小,因此用片上的RAM就足够了(EP2C35支持4KB的片上RAM),在指定vector的时候,也都指定为RAM

 

2

../hello_led.c: In function `alt_main':

../hello_led.c:141: error: `LED_PIO_BASE' undeclared (first use in this function)

../hello_led.c:141: error: (Each undeclared identifier is reported only once

../hello_led.c:141: error: for each function it appears in.)

make: *** [obj/hello_led.o] Error 1

Build completed in 3.734 seconds

原因:

在用IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led)函数时,参数LED_PIO_BASE中的LED_PIOPIO的名称,所以在编译的时候,会说LED_PIO_BASE未被定义

解决方法:

SOPC_BUILDER中,把PIO的名称改为LED_PIO,重新生成CPU,并进行编译即可。

 

3

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00

Pausing target processor: not responding.

Resetting and trying again: FAILED

Leaving target processor paused

原因:

CPUreset没有输入

解决方法:

CPUreset加入一个输入,我的板子上有一个RESET输入,接在TD_RESET引脚上,直接加上就可以解决了

 

1

2

你可能感兴趣的:(exception,vector,function,validation,each,generation)