accessing memory-mapped registers on a pci dio card

hi,
I am trying to write to a dio port on a dio card on the pci bus. I am not
having any luck. Any input would be greatly appreciated.
I ran the show_pci utility I downloaded from quics. I can detect the
dio card. I get the correct card id and vendor id. The show_pci utility
tells me an address in memory that the card maps to(0xf4002000). Here is a
summary of the code I am using.

volatile unsigned char *addr, *portc;
int fd

fd = shm_open(“Physical”, O_RDWR, 0777);
addr=mmap(0,PAGESIZE,PROT_READ|
PROT_WRITE, MAP_SHARED, fd,
0xf4002000);
portc=addr+2;
/* the port I am trying to write to is at an offset of 0x02 from the
begining of of the memory mapped area */
while(!kbhit()) {
*portc=0x07;
delay(100);
*portc=0x00;
delay(100)
}

My program does the appropriate error checking to make sure that shm_open()
and mmap are working(). I am checking the bits on the port to see if they
change. Is there something I can do to make sure that the value is written
to that memory location? Any comments would be greatly appreciated.

thanks,
Doron

Doron <doron@cfi.ucsb.edu> wrote:

hi,
I am trying to write to a dio port on a dio card on the pci bus. I am not
having any luck. Any input would be greatly appreciated.
I ran the show_pci utility I downloaded from quics. I can detect the
dio card. I get the correct card id and vendor id. The show_pci utility
tells me an address in memory that the card maps to(0xf4002000). Here is a
summary of the code I am using.

volatile unsigned char *addr, *portc;
int fd

fd = shm_open(“Physical”, O_RDWR, 0777);
addr=mmap(0,PAGESIZE,PROT_READ|
PROT_WRITE, MAP_SHARED, fd,

Map it with PROT_NOCACHE. Otherwise your write can go to CPU cache,
and may be delayed before it gets out to the hardware.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

thanks for your response David.
I added PROT_NOCACHE to mmap, but it didn’t solve my problem. Any other
ideas?


“David Gibbs” <dagibbs@qnx.com> wrote in message
news:a6qjoa$bkg$1@nntp.qnx.com

Doron <> doron@cfi.ucsb.edu> > wrote:
hi,
I am trying to write to a dio port on a dio card on the pci bus. I am
not
having any luck. Any input would be greatly appreciated.
I ran the show_pci utility I downloaded from quics. I can detect
the
dio card. I get the correct card id and vendor id. The show_pci
utility
tells me an address in memory that the card maps to(0xf4002000). Here
is a
summary of the code I am using.

volatile unsigned char *addr, *portc;
int fd

fd = shm_open(“Physical”, O_RDWR, 0777);
addr=mmap(0,PAGESIZE,PROT_READ|
PROT_WRITE, MAP_SHARED, fd,

Map it with PROT_NOCACHE. Otherwise your write can go to CPU cache,
and may be delayed before it gets out to the hardware.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.