Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - IO-Address for mmap_device_io with PC-104: (7 Items)
   
IO-Address for mmap_device_io with PC-104  
I'm running QNX 6.5 on an Advantech PCM-3350 PC-104 stack with a Sensoray 526 Multifunction I/O card. It seems as though
 the best way to access the ports on this is through the registers, and it seems as though the best way to do that is by
 setting up with mmap_device_io(). However, I have no idea how to find base address for the IO card.

Any help would be greatly appreciated.
Re: IO-Address for mmap_device_io with PC-104  
I saw a similar question recently and the answer referred to the manual

http://www.mathworks.com.au/support/solutions/en/data/1-57FT94/index.html?product=XP&solution=1-57FT94

Page 17
"Jumpers marked ADDR15-6 select the higher 10 bits of the board’s base address in I/O space.
Inserted jumper sets the corresponding bit to 0. The board ships with base address set to 0x2C0."
Re: IO-Address for mmap_device_io with PC-104  
Great, thank you.

I probably read that a few times and didn't realize that was what I was looking for, I assumed the address was set by 
the OS.

My next question involves the other input to mmap_device_io, the "length." Each register is 16 bits, so is the length 2 
(2 bytes)? Or is it 27 ("Model 526 is controlled through a set of 27 registers mapped into I/O space")?
Re: IO-Address for mmap_device_io with PC-104  
The registers are 16 bit (2 bytes) as you said.  There are 27 registers = 54 bytes.
This is supported by 6 low order address lines suggesting a maximum of 64 byte IO space.

Length = 54 bytes

uintptr_t   ioPtr = mmap_device_io (54, 0x2c0);    // for the factory supplied base address

Don't forget the     ThreadCtl(_NTO_TCTL_IO, 0)    call to get IO privileges.

Re: IO-Address for mmap_device_io with PC-104  
Hmmm so I had been using 

uintptr_t   ioPtr = mmap_device_io (2, 0x2c0);    // for the factory supplied base address

And it has been working fine for now, will this cause problems in the future?
Re: IO-Address for mmap_device_io with PC-104  
Strictly - you should only be able to access the first register (Timer control) - anything else is outside the mapped 
space and should fail with a SIGSEGV.

This suggests very loose limits checking!  For safety, don't depend on this behavior - it might be 'fixed' in a new 
release/patch.
Re: IO-Address for mmap_device_io with PC-104  
Ok great, thanks a lot for the help.

I'm working on a new problem now, in that I'm trying to use this system for real time control of a robotic system. I'd 
like to have a control loop run at say 1khz, and maybe a loop that checks the sensors at some other frequency, I'm very 
lost as to how to go about implementing this.

I can't really use the hardware counters/timers on the Sensoray 526 I have as I 3 of them for encoder inputs so I'd like
 to use another method. I find the documentation really lacking on how to go about doing this, should I use 
InterruptAttach()? InterruptAttachEvent()? have the clock send a pulse or message?

I can't find any really good documentation or sample code for this sort of problem. I know people are doing things like 
this and so it must not be that hard, but accurate loop timing is one of the reasons I decided to use the QNX RTOS.