Sorry to drag up a new thread, but when I run this line, my 7260 just
sits there a long time, waiting for this to execute. I really dont
know what this does, so can anyone help me?
48 while(!(*adcommand & (1 << ADREADYBIT)));
i have changed his source code to read a given line and return the
voltage as a float. here's the code I changed.
thanks for the help
brandon
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#define BASE 0x11C00000
#define ADBASE 0x168
#define ADCOMMAND ADBASE
#define ADDATA 0x16A
#define LDAC 0x16C
#define MDAC 0x16D
#define ADREADYBIT 7
#define NUM_CHANNELS 5
typedef unsigned char byte;
float getA2Dline(int lineNumber)
{
byte *base;
volatile byte *adcommand;
volatile byte *lsb;
volatile byte *msb;
volatile byte *ldac;
volatile byte *hdac;
unsigned short int val;
int fd;
float volts;
int i;
fd = open ("/dev/mem" , O_RDWR|O_SYNC);
base = (byte *)mmap(0, getpagesize(), PROT_READ | PROT_WRITE,
MAP_SHARED, fd, BASE);
adcommand = base + ADCOMMAND;
lsb = base + ADDATA;
msb = base + ADDATA + 1;
ldac = base + LDAC;
hdac = base + MDAC;
val = 255;
//val |= (0x0 << 14);
*ldac = val;
val = 7;
*hdac = val;
*adcommand = lineNumber;
while(!(*adcommand & (1 << ADREADYBIT)));
volts = (256 * *msb + *lsb) * 2.5 / 4096;
return volts;
}
--- In "ugumugu" <> wrote:
>
> The code succesfully compiled and running on the sbc.
>
> Thank you all for your advices.
>
> Now the below code is working
>
> Best Regards
>
> ugurtan
>
>
>
>
> #include <stdio.h>
> #include <fcntl.h>
> #include <sys/mman.h>
>
> #define BASE 0x11C00000
> #define ADBASE 0x168
> #define ADCOMMAND ADBASE
> #define ADDATA 0x16A
> #define LDAC 0x16C
> #define MDAC 0x16D
>
> #define ADREADYBIT 7
> #define NUM_CHANNELS 5
>
> typedef unsigned char byte;
>
> main(){
> byte *base;
> volatile byte *adcommand;
> volatile byte *lsb;
> volatile byte *msb;
> volatile byte *ldac;
> volatile byte *hdac;
> unsigned short int val;
>
> int fd;
> float volts;
> int i,j;
> fd = open ("/dev/mem" , O_RDWR|O_SYNC);
> base = (byte *)mmap(0, getpagesize(), PROT_READ | PROT_WRITE,
> MAP_SHARED, fd, BASE);
> adcommand = base + ADCOMMAND;
> lsb = base + ADDATA;
> msb = base + ADDATA + 1;
> ldac = base + LDAC;
> hdac = base + MDAC;
>
> val = 255;
> //val |= (0x0 << 14);
> *ldac = val;
> val = 7;
> *hdac = val;
>
>
>
> while (1) {
> for (j=0; j<NUM_CHANNELS; j++)
> {
> *adcommand = j;
> while(!(*adcommand & (1 << ADREADYBIT)));
> volts = (256 * *msb + *lsb) * 2.5 / 4096;
> printf ("%1.3f ",volts);
> }
> printf("\n");
> usleep(100000);
> }
> }
>
>
>
>
>
>
>
>
>
>
>
>
> --- In "Andy Mercier" <andynmercier@> wrote:
> >
> > --- In "ugumugu" <ugu@> wrote:
> > >
> > > Hi everybody,
> > >
> > > I use below source to use the ts9700,
> > >
> > > While everything on the ADC part is perfect, there is no output
on the
> > > DAC side.
> > >
> > > Could you please give me some advice on it.
> > >
> > >
> > > Best Regards.
> > > F. Ugurtan Erdem
> > > *******************
> > >volatile byte *ldac;
> > >volatile byte *hdac;
> > > :
> > > :
> > >ldac = base + DAC;
> > >hdac = base + DAC + 1;
> > > :
> > > :
> > > *ldac = val;
> > > *hdac = 0xFF;
> > > :
> > > ***********************************
> > >
> >
> > Are you compiling with "-mcpu=arm9"?
> >
> > Ref. last paragraph of section 7.4 in
> > http://www.embeddedarm.com/Manuals/linuxarm-guide-rev2.3.pdf
> >
> > ----
> > Andy
> >
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|