Forum Discussion
Altera_Forum
Honored Contributor
15 years ago --- Quote Start --- Dear donq first like to thank you for the reply and assistance. I did exactly what you mentioned. Using the SOPC builder prepending my hardware structure below the element, made the generation of project files HW (which was included in my file system.h) and run the compilation. //system.h ---------------------------------------------------------------------- /* * gpio_0 configuration * */ # define GPIO_0_NAME "/dev/gpio_0"# define GPIO_0_TYPE "altera_avalon_pio"# define GPIO_0_BASE 0x00681110# define GPIO_0_SPAN 16# define GPIO_0_IRQ 6# define GPIO_0_DO_TEST_BENCH_WIRING 0# define GPIO_0_DRIVEN_SIM_VALUE 0# define GPIO_0_HAS_TRI 0# define GPIO_0_HAS_OUT 0# define GPIO_0_HAS_IN 1# define GPIO_0_CAPTURE 1# define GPIO_0_DATA_WIDTH 32# define GPIO_0_EDGE_TYPE "ANY"# define GPIO_0_IRQ_TYPE "EDGE"# define GPIO_0_BIT_CLEARING_EDGE_REGISTER 0# define GPIO_0_FREQ 100000000# define ALT_MODULE_CLASS_gpio_0 altera_avalon_pio ---------------------------------------------------------------------- After the process of compiling the file checked Pin-Out was in line with the Pin Planner, and once again everything was ok. In the Nios, I created a basic design to test where I inserted the following C code: ----------------------------------------------------------------------# include "system.h"# include "altera_avalon_pio_regs.h"# include "alt_types.h"# include <stdio.h> int main (void) __attribute__ ((weak, alias ("alt_main"))); int alt_main (void) { alt_u8 led = 0x2; volatile int i; while (1) { led = IORD_ALTERA_AVALON_PIO_DATA(GPIO_0_BASE); printf("GPIO = %d\n", led); IOWR_ALTERA_AVALON_PIO_DATA(LED_GREEN_BASE, led); i = 0; while (i<200000) i++; } return 0; } ---------------------------------------------------------------------- When running the application do the above test with the sensor to verify presence by detecting the presence the GPIO can get the correct answer, but the only result is: GPIO = 0 GPIO = 0 GPIO = 0 ... Remember, the sensor is powered by a 9v battery and the yellow wire (GND) of the same is connected to pin 12 of GPIO_0 (JP1) and green wire (Data) is connected to pin 1 of the same GPIO. Want to know what is wrong in my application NIOS and how do I do it? Again, thank you all. --- Quote End --- It is noteworthy that in my file Pin-Out all GPIO_0 [n] holds the same values for the fields "Dir.:", I/O Standard:, Voltage:, I/O Bank:, User Assignment" --------------------------------------------------------------------------------- -- Pin directions (input, output or bidir) are based on device operating in user mode. --------------------------------------------------------------------------------- Quartus II Version 7.2 Build 151 09/26/2007 SJ Web Edition CHIP "DE2_NIOS" ASSIGNED TO AN: EP2C35F672C6 Pin Name: Location: Dir.: I/O Standard: Voltage: I/O Bank: User Assignment ------------------------------------------------------------------------------------------------------------- ... GPIO_0[0]: D25 : bidir: 3.3-V LVTTL : : 5 : Y ... Thank you.