I am trying to get the Analog TS9700 Board to interface with my TS7250
Arm board but have hit a wall.
Here is the code I tried using to access the Analog board. I am really
only concernd with the DAC at this point.
#define PC8BITIO 0x11E00000
#define PC16BITIO 0x21E00000
#define PC8BITMEM 0x11A00000
#define PC16BITMEM 0x21A00000
Tpc104::Tpc104()
{
fd = open("/dev/mem", O_RDWR);
if(fd == 1)
throw("Unable to open /dev/mem");
pc8io = (unsigned char *)mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, PC8BITIO);
pc16io = (unsigned short *)mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, PC16BITIO);
if(pc8io == MAP_FAILED || pc16io == MAP_FAILED)
throw("Unable to map memory");
}
//-------------------------------------------------------------------
Tpc104::~Tpc104()
{
close(fd);
}
//-------------------------------------------------------------------
void Tpc104::outp(int port, unsigned char data)
{
printf("Writing 0x%X,0x%X\n", (port+PC8BITIO), data);
*(pc8io + port) = data;
}
//-------------------------------------------------------------------
void Tpc104::outpw(int port, unsigned short data)
{
printf("Writing 0x%X,0x%X\n", port+PC16BITIO, data);
*(pc16io + port) = data;
}
The Tdac inherits the above class.
#define MAX_CHANNELS 4
#define DAC_BASE 0x160
#define DAC_STATUS DAC_BASE+6
#define DAC_DATA DAC_BASE+4
#define DAC_LSB DAC_BASE+4
#define DAC_MSB DAC_BASE+4
void Tdac::set(int channel, unsigned short val)
{
channel &= 0x3; // Only allow ch 0-3
// channels[channel] = val; // Save previous value
val |= (channel << 14); // Setup port to write
//while(!(inp(DAC_STATUS) & 0x80));
/*outp(DAC_LSB, val & 0xFF);
outp(DAC_MSB, (val & 0xFF00) >> 8);
*/
outpw(DAC_DATA, val);
printf("Setting DAC #%i to B", channel);
printbin(val);
}
In my main I create a Tdac object and then call
dac.set(0,0xAAA);
I have coded the same style for the LED's and the LCD DIO and it works
correctly. I have also tried this using the PC8/16MEM but still nothing.
I also tried simplifying the above code so all did was write a single
value to the port after remapping the memory and still nothing.
Does anybody notice anything I did wrong above or something I didn't do?
I would like to see some sample code on the PC104 using an ARM
Processor if anybody has anything. Iv'e seen lots of code for intel
based boards but they have quite a bit different access methods.
Thanks for any help,
Cliff
SPONSORED LINKS
YAHOO! GROUPS LINKS
- Visit your group "ts-7000" on the web.
- To unsubscribe from this group, send an email to:
=Unsubscribe
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.