Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

Question about #include in NIOS II?

I have built the following file:

#include <stdio.h># include "system.h"# include "altera_avalon_pio_regs.h"# include "altera_up_avalon_rs232.h"
int main()
{
  printf("Hello from Nios II!\n");
  int count = 0;
  int delay;
  while(1)
  {
      IOWR_ALTERA_AVALON_PIO_DATA(PIO_LED_BASE, count & 0x01);
      delay = 0;
      alt_up_rs232_write_data('hi');
      while(delay<2000000)
      {
          delay ++;
      }
      count ++;
  }
  return 0;
}

---My system recognizes the first 3 includes but has a problem recognizing # include "altera_up_avalon_rs232.h" It says this file doesnt exist.

Why is this?

# include "altera_avalon_pio_regs.h" is located at:

C:\altera\11.1sp1\ip\altera\sopc_builder_ip\altera_avalon_pio

and

# include "altera_up_avalon_rs232.h" is located at:

C:\altera\11.1sp1\ip\University_Program\Communications\altera_up_avalon_rs232

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The name of the directory containing the include file needs to be passed to the compiler as a -I <dir_name> parameter.

    The IDE probably has a list of such names somewhere, the directory you need won't be in the default list.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I found the easiest way to add .c or .h files to a project is just drag and drop the files from the folder onto the project explorer folders.