Start a new topic

Using TS-DIO24 expansion - how to set a pin?

This is basic stuff, but I can't quite see how to set values on the I/O pins for a expansion board. I have the TS-DOI24

https://wiki.embeddedarm.com/wiki/TS-DIO24

 mated to the TS-7240-V2

https://wiki.embeddedarm.com/wiki/TS-7250-V2#ADC


The DIO24 manual mentions BASE+5 for say, the PortA register and I have jumpers off so address selection I/O address is "Base+0x100". Is Base the PC/104 base for 7250? I've noticed for EVGPIO documentation, say I/O 9 is PC104_A1... does that have anything to do with TS-DIO24's A1?


I'd love to use evgpio.c or tshwctl.c. I've tried compiling these with the first few lines changed to use a new address. Like changing the syscon address from 0x80004000 to 0x80004100, but that seems wrong (and doesn't work!).


So any pointers? I'd imagine this is a one-line code change, or there's already a .c program out there to toggle a pin?


Thank you!

Rick


Good morning Rick,

I see your confusion.  There are two PC104 chapters in the TS-7250-V2 manual.  I think you're looking for this section here:

https://wiki.embeddedarm.com/wiki/TS-7250-V2#PC104


The default PC104 base address for an 8-bit peripheral (such as the DIO24) is 0x81008000.


Note this is different from tshwctl and does not use the evgpio core.  The PC104 peripheral's registers will be accessed in code using some form of mmap()... for example:


This code will set up a memory map to the 16-bit PC104 space, read and output the Board ID at offset 0x100, and exit.


#include <stdio.h>

#include <stdint.h>

#include <unistd.h>

#include <sys/mman.h>

#include <sys/fcntl.h>

int main(void)

{

  int id = 0;

  volatile uint16_t *membase = NULL;

  int mem = 0;

  const int offset = 0x100;

  mem = open("/dev/mem", O_RDWR|O_SYNC);

  membase = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_SHARED, mem, 0x80008000);

  id = membase[offset/2];

  printf("X100_ID=0x%4X\n", id);

  return 0;

}




  


1 person likes this

I appreciate the code! I'm making progress but got stuck for most of the day on this now: I think I'm missing something that I'm sure you can clear up - it may be related to that comment you made about the bus cycles. It looks like I'm only reading even registers, and I can't seem to set any permanently (note output line A is different than line C, but it's the same code). Is there a specific wait I need to do?


I really appreciate your time - I'm sure this is a quick fix. And your example code had 0x80008000, so I'm using that, if I use 0x81008000 (the DIO being 8 bit...) the results are the same except that 0xF6 is always just a mirror of the lower byte (so Base+0 = 0x5454, e.g.)


- Rick


Image is output with JP4 set to on, so we expect 0x18 in Base+2 and 0x02 in Base+4.

dio24.png
(57.6 KB)

Well that picture got shrunk down a lot!


image



https://i.imgur.com/yyp9nxo.png


Ah, I think I got it. I changed the code to use uint8_t instead of uint16_t and stopped dividing by 2.

Login or Signup to post a comment