Thanks for the help. I was able to get the DAC working today by using the
11E00165 or 11C00165 addresses, and using 2 io cycles for the write.
I have looked closer at the documentation and see 3 possible address
regions for accessing the PC104 Interface.
11C00000 - 8 Bit
11E00000 - 8 Bit Legacy
71C00000 - CS7 8 Bit (User selectable timing)
What are the differences?
Now that I have verified the board actually works I tried to move the code
into my kernel module. I now recieve segmentation faults every time I try
to write to the 11C00164 or the 11E00164.
I used the following code to try this.
outb(0xFF, 0x11C00164); // Also using 11E00164
outb(0x0F, 0x11C00165); // Also using 11E00165
I have successfully used the LED's, setup Interrupts and other devices
using exactly the same outb commands above and recieved no segfaults.
e.g.
outb(0x01, 0x80840020); // Turn on LED ( No Segfault Here)
I have also tried using the kernel ioremap_nocache() to remap the memory
and then using the writeb() command. By using this method I don't get any
segfaults but if doesn't seem to work at all. I have tried using this
method with the LED and it also would not work.
Is there something to do with the MMU I have to configure?
Unfotunatly I want to run in kernel space so I can have my Periodic
Interrupt Service Routine Read from the DAC and output to the ADC without
polling from userspace and wasting the CPU.
Does anybody have any idea why this is causing a segmentation fault?
I would be glad to post this code once complete so others don't have to go
through the same troubles I have encoutered.
Thank you,
Cliff
> Hello Cliff,
>
> I am using the TS9700 with the TS7200...
>
> Accordning to the pdf on the files section the Base address is
> 0x11C00000 for both platforms (7200 and 7250)
>
> and this the base address I use in my programs
> I am running NetBSD and I have achieved around 38Ksps
>
> Are you running Linux ?
Yes.
> I think that all the includes are the same so this litle prog can run
> directly
>
> Maybe you can post your maximum sampling speed...
>
I would be glad to when I get this all working.
>
> below is a small program that reads the ADC ch0 for 25000 times and then
> prints the first 10 results
>
> ---------------------------------------------
>
> #include <stdio.h>
> #include <fcntl.h>
> #include <sys/time.h>
> #include <sys/mman.h>
> #include <stdlib.h>
> #include <unistd.h>
>
> int main(){
> unsigned long i;
> int k;
> int bit_7;
> volatile unsigned short *RESULT_REG;
>
> volatile unsigned char *base;
> volatile short *iptr;
> iptr = (short *)malloc(sizeof(unsigned short));
>
>
> int fd = open("/dev/mem", O_RDWR);
> base = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
> 0x11C00160 );
>
> i = 0;
> bit_7=0;
>
> RESULT_REG = (unsigned short *)(base + 0x02); // two byte read
>
> printf("Start loop\n");
> *base = 0x00;
>
> while ( i < 25000 ) {
>
> do {
> bit_7 = *base & 0x80;
> } while (bit_7 == 0);
>
> iptr[i] = *RESULT_REG;
> *base = 0x00;
> i++;
> }
>
> printf("End loop\n");
> k = 0;
> while ( k < 10){
> fprintf(stdout, "%1.13f\n", iptr[k]*0.0006103515625);
> k++;
> }
>
> return(0);
> }
>
>
>
>
>
> On 12/4/05, Cliff Blackburn <> wrote:
>>
>> 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
>> Computer internet
>> security<http://groups.yahoo.com/gads?t=ms&k=Computer+internet+security&w1=Computer+internet+security&w2=Linux+os&w3=Computer+internet+business&w4=Computer+internet+access&w5=Computer+internet+help&w6=Single+board&c=6&s=154&.sig=3sOvxqNXPmErHHoO5HP6BQ>
>> Linux
>> os<http://groups.yahoo.com/gads?t=ms&k=Linux+os&w1=Computer+internet+security&w2=Linux+os&w3=Computer+internet+business&w4=Computer+internet+access&w5=Computer+internet+help&w6=Single+board&c=6&s=154&.sig=rQFJcREyACaxkt_846oEkg>
>> Computer
>> internet
>> business<http://groups.yahoo.com/gads?t=ms&k=Computer+internet+business&w1=Computer+internet+security&w2=Linux+os&w3=Computer+internet+business&w4=Computer+internet+access&w5=Computer+internet+help&w6=Single+board&c=6&s=154&.sig=S_p52cPugmLDIqw2aLoD3A>
>> Computer
>> internet
>> access<http://groups.yahoo.com/gads?t=ms&k=Computer+internet+access&w1=Computer+internet+security&w2=Linux+os&w3=Computer+internet+business&w4=Computer+internet+access&w5=Computer+internet+help&w6=Single+board&c=6&s=154&.sig=MfUoUrpd22Y8ur_dkn7Y1g>
>> Computer
>> internet
>> help<http://groups.yahoo.com/gads?t=ms&k=Computer+internet+help&w1=Computer+internet+security&w2=Linux+os&w3=Computer+internet+business&w4=Computer+internet+access&w5=Computer+internet+help&w6=Single+board&c=6&s=154&.sig=Abw1lgORYz53LHq36_akDg>
>> Single
>> board<http://groups.yahoo.com/gads?t=ms&k=Single+board&w1=Computer+internet+security&w2=Linux+os&w3=Computer+internet+business&w4=Computer+internet+access&w5=Computer+internet+help&w6=Single+board&c=6&s=154&.sig=Ca63SBKBz3lIrNCBC3GSRA>
>> ------------------------------
>> YAHOO! GROUPS LINKS
>>
>>
>> - Visit your group "ts-7000 <http://groups.yahoo.com/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 <http://docs.yahoo.com/info/terms/>.
>>
>>
>> ------------------------------
>>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
1.2 million kids a year are victims of human trafficking. Stop slavery.
http://us.click.yahoo.com/.QUssC/izNLAA/TtwFAA/CFFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|