ts-7000
[Top] [All Lists]

[ts-7000] Re: Strange shifting variables

To:
Subject: [ts-7000] Re: Strange shifting variables
From: "berryma4" <>
Date: Tue, 01 Apr 2008 13:12:38 -0000

Hello!

I'm still having problems understanding what's wrong.  I've made some
changes (below is a new code snippet), adding the volatile and my g++
looks like this: 

/usr/bin/arm-linux-g++ -c   -D_POSIX_C_SOURCE=199506L -D_POSIX_THREADS
-D_XOPEN_SOURCE=500        -D_ARM_NWFP_  -DUNIX  -D_BSD_SOURCE -Dlinux
 -D_REENTRANT -ansi -mcpu=arm9 -DLITTLE_ENDIAN -O3  -Wall 

and gcc:

/usr/bin/arm-linux-gcc -c   -D_POSIX_C_SOURCE=199506L -D_POSIX_THREADS
-D_XOPEN_SOURCE=500        -D_ARM_NWFP_  -DUNIX  -D_BSD_SOURCE -Dlinux
 -D_REENTRANT -ansi -mcpu=arm9 -DLITTLE_ENDIAN -O2  -Wall


It seems like I don't understand what I'm writing to.  
 preg->regOff = (TS_OUTB_DPORT_A)  //This doesn't work
 preg->regOff = (TS_OUTB_DPORT_A << 16)  //While this does



typedef struct Port Port;


/* Declare register info structure */
typedef struct Reg_struct
{
    volatile unsigned int isConn;
    volatile unsigned int cfgIdx;
    volatile unsigned int cfgOff;
    volatile unsigned int regOff;
    volatile unsigned int regNum;
    volatile unsigned int regDir;
} Reg;

static asynStatus create(void* ppvt,asynUser* pasynUser,const char*
drvInfo, const char** pptypeName,size_t* psize)
{
    int addr = -1;
    volatile Reg* preg = NULL;
    volatile Port* pport = (Port*)ppvt;

    switch( pport->type )
    {
    case TS_7200:
printf("XX0: 0x%x\n",preg->cfgOff);
printf("XX1: 0x%x\n",preg->regOff);

        if( addr < 1 ){
           preg->cfgOff = (TS_DIOCR_DIRA << 16);
printf("DirA: 0x%x 0x%x\n",preg->cfgOff,TS_DIOCR_DIRA);}

        else if( addr > 0 ){
           preg->cfgOff = TS_DIOCR_DIRB;
printf("DirB: 0x%x\n",preg->cfgOff);}
printf("AA0: 0x%x\n",preg->cfgOff);

        if( addr == 0 ){
            preg->regOff = (TS_OUTB_DPORT_A << 16);
printf("PortA: 0x%x 0x%x\n",preg->regOff,TS_OUTB_DPORT_A);}

        else if( addr == 1 ){
            preg->regOff = TS_OUTB_DPORT_B;
printf("PortB: 0x%x\n",preg->regOff);}

        else        {           
asynPrint(pasynUser,ASYN_TRACEIO_FILTER,"drvDio::create %s: invalid
register number %d\n",pport->name,addr);
            return( asynError );        }        

printf("AA1: 0x%x\n",preg->cfgOff);
printf("Break: 0x%x\n",preg->regOff);
        break;
    } // switch is done

printf("Done: 0x%x\n",preg->regOff);


output (with <<16):

XX0: 0x14
XX1: 0x4
DirA: 0x14 0x14
AA0: 0x14
PortA: 0x4 0x4
AA1: 0x14
Break: 0x4
Done: 0x4
4
4
preg->cfgOff
preg->regOff=4


output (without <<16):
XX0: 0x140000
XX1: 0x40000
DirA: 0x140000 0x14
AA0: 0x140000
PortA: 0x40000 0x4
AA1: 0x140000
Break: 0x40000
Done: 0x40000
4
4
preg->cfgOff=1310720
preg->regOff=262144


Thank you for any help!
Eric



--- In  "Andy Mercier" <> wrote:
>
> Insure that your pointers to registers are declared with "volatile".
> 
> Frequently programmers, including me (only sometimes), think there's a
> compiler bug but it turns out it's poor programming. Remember, there's
> a good chance that the compiler version you're using has been used to
> build the Linux kernel and the compiler was probably also used to
> build itself (or the next version of the compiler). Usually, if that
> kind of compilation is done it will show compiler bugs. Your code is
> still pretty simple in comparison (and most of mine is too).
> 
> ----
> Andy
> 
>  --- In  "berryma4" <berryma4@> wrote:
> >
> > 
> > 
> > Thank you!
> > 
> > I wasn't using the -mcpu=arm9 option, but now I am.  But
> > unfortunately, I'm still getting this shift ... but only on arm .. my
> > code doesn't do this on my x86 board.  So, the data is written to a
> > register after the case statement, ... what happens to it next?  Why
> > the shift?  Seems like a compiler optimization problem.
> > 
> > Thank you for any help!
> > Eric
> >
>



------------------------------------

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/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU