Hello, I am new to the TS-7300 and am trying to get my DIO2 to work as
inputs. I have already successfully gotten them to work as outputs
using similar code. The output of this program reads 0 at all times.
I am using the 3.3V pin to get a voltage on to on of the input pins.
I am trying to determine if it is either my code or how I am
connecting to the inputs that is the problem....
#define GPIOBASE 0x72000000
#define XDIO2_CTRLR 0x44
#define XDIO2_DATAR 0x45
#define XDIO2_DDR 0x46
int fd; /* /dev/mem file descriptor */
int page_size = getpagesize();
unsigned char *mem_addr = NULL;
unsigned int mem_phys = GPIOBASE;
unsigned char num;
volatile unsigned char *port2_ctrl;
volatile unsigned char *port2;
volatile unsigned char *port2_dir;
/* Open a page at the FPGA base address */
fd = open("/dev/mem", O_RDWR | O_SYNC);
if (fd < 0) {
printf("Open /dev/mem failed - %s\n",
strerror(errno));
return -1;
}
mem_addr = (char *)mmap(
0,
page_size,
PROT_READ|PROT_WRITE,
MAP_SHARED,
fd,
mem_phys);
if (mem_addr == (unsigned char *)MAP_FAILED) {
printf("Error: mmap failed\n");
close(fd);
return -1;
}
port2_ctrl = mem_addr + XDIO2_CTRLR;
port2_dir = mem_addr + XDIO2_DDR;
port2 = mem_addr + XDIO2_DATAR;
*port2_ctrl = 0; /* IO mode */
*port2_dir = 0x00; /* All inputs */
while(1){
num = *port2;
printf("%X\n", num);
}
return 0;
Thank you,
Scott
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|