![]() |
| | #1 |
| Registered User Join Date: Feb 2009
Posts: 278
| Reading a 16 bit Register I am using an ADC board (See Getting Started Sheet) attached to an SBC running DOS 6.2. There is only a sparse and seemingly rough documentation for the ADC. The board has a FIFO for reading the 24 channels. When I read from address BASE+0x0A (ADCFIFO), and then the internal pointers should advance to the next channel from the FIFO (Each address is actually 16-bit. I'm using inport(ADC_FIFO_REG) to read the data from the ADC. However, for some reason, the FIFO pointer actually moves 2 channels instead of 1. If I use inportb(ADC_FIFO_REG) (and therefore only get the LSB) the internal pointer only moves one channel. So I tried reading each byte of the FIFO in turn (I tried in both possible orders) which, again, caused the FIFO to advance 2 channels. Is there another function or method I could use to read these registers? I have a feeling that there is an issue with the board itself, but then it could just be that I feel that way because of the pretty crappy state of the "manual" that they have for this board. Any suggestions are welcome. I will post the full code if necessary. Thanks, Lee |
| Bladactania is offline | |
| | #2 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| How about inportw() ?
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #3 |
| Registered User Join Date: Feb 2009
Posts: 278
| I get an undefined error for inportw() |
| Bladactania is offline | |
| | #4 |
| Registered User Join Date: Feb 2009
Posts: 278
| I tried using inp(), inpw(), inport(), and inportb(). |
| Bladactania is offline | |
| | #5 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| Write your own. Call it inportw() Containing a few asm instructions to input a 16 bit value from a port.
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #6 |
| Registered User Join Date: Feb 2009
Posts: 278
| asm? |
| Bladactania is offline | |
| | #7 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Code: short x = inport(0x123); You will need to include "dos.h" (it may well be that it's a macro rather than a function, perhaps). If that doesn't work, then as Salem says, you may need to write your own inline-assembler function. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #8 |
| Registered User Join Date: Feb 2009
Posts: 278
| Yeah that's what I originally tried (inport). I've never written inline assembler functions before... always fun to learn something new |
| Bladactania is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Segmentation fault ith g_type_check_class_cast () from /usr/lib/libgobject-2.0.so.0 | lehe | Game Programming | 7 | 02-02-2009 07:27 AM |
| SSH Hacker Activity!! AAHHH!! | Kleid-0 | A Brief History of Cprogramming.com | 15 | 03-06-2005 03:53 PM |
| bit patterns of negtive numbers? | chunlee | C Programming | 4 | 11-08-2004 08:20 AM |
| Register | sean345 | C Programming | 7 | 05-08-2002 03:06 PM |
| 16 bit colors | morbuz | Game Programming | 13 | 11-10-2001 01:49 AM |