Forums

Problem with C31 , Please help me

Started by mm_k...@yahoo.com October 4, 2006
Hello all,
I design an evaluation board with TMS320C31 and i have a problem,
I write a program in C and compile it with CC4.1, when i use this line :

retval += *ptr & 0x00000fff;

the "retval" is fill by wrong value. But when i change program to following lines, the answer is correct:

dat= *ptr;
asm(" nop ");
dat &= 0x00000fff;
asm(" nop ");
retval += dat;

(ptr is address of an I/O port)

I don't know why? If anybody can help, please informe me.

thanks,
kashi.
Hello Kashi

Your code fragment is a little 'thin' so I must make guesses. For
example, are these fragments contained in functions? Also look at
'retval. Is retval declared global or local? If it is local, is it
static volatile to tell the compiler it can change between calls.

volatile <- This keyword is different than the static or global
declaration. It tells the compiler that an external process can modify
the previous value. This keyword tells the compiler it cannot assume
the last time the program visited this variable that it is still the
same value.

These issues are quite often related to the optimizer and or HLL source
debugging (stack is handled differently). To get to the bottom of this
one try using the cl30 '-k' option to generate and keep the ASM files.

Best regards
Keith

tip: If you forget the CL30 options, type the following from the command
line. With no options, CL30 outputs a list of options. The '>' symbols
is the DOS piping command that causes stdout to be copied to a file
rather than to the screen.

C:\DSK3\DSK3\CL30 >CL30_OPN.TXT

----------------------------------
m...@yahoo.com wrote:

Hello all, I design an evaluation board with TMS320C31 and i have a
problem, I write a program in C and compile it with CC4.1, when i use
this line :

retval += *ptr & 0x00000fff;

the "retval" is fill by wrong value. But when i change program to
following lines, the answer is correct:

dat= *ptr;
asm(" nop ");
dat &= 0x00000fff;
asm(" nop ");
retval += dat;

(ptr is address of an I/O port)

I don't know why? If anybody can help, please informe me.

thanks, kashi.
Kashi,

What are the C types of dat, ptr, and retval? When you say ptr is an
I/O port, what do you mean, exactly? An MMR? or something on the
Expansion Bus? Are your wait states set correctly? How is the answer
incorrect?

Have you looked at the disassembly?

Bill

> -----Original Message-----
> From: c... [mailto:c...] On
> Behalf Of m...@yahoo.com
> Sent: Wednesday, October 04, 2006 12:48 AM
> To: c...
> Subject: [c3x] Problem with C31 , Please help me
>
> Hello all,
> I design an evaluation board with TMS320C31 and i have a problem,
> I write a program in C and compile it with CC4.1, when i use
> this line :
>
> retval += *ptr & 0x00000fff;
>
> the "retval" is fill by wrong value. But when i change
> program to following lines, the answer is correct:
>
> dat= *ptr;
> asm(" nop ");
> dat &= 0x00000fff;
> asm(" nop ");
> retval += dat;
>
> (ptr is address of an I/O port)
>
> I don't know why? If anybody can help, please informe me.
>
> thanks,
> kashi.
>