Problem with uprintf() when compiled in multiple files.
I have three source code files, p2a-reva.c, fpga_IO.c, and serial_IO.c.
The first one is where main() resides. The file fpga_IO.c has a call to
uprintf() with a transmit character function pointer to txChar().
When I compile it as a single file (#include the latter two files into
the first file), it generates good code in which the setup before a call
to uprintf() consists of two push opcodes. The first push points to the
format string and the second push points to the txChar function.
The problem I have is that when I compile the code with the following
command:
msp430-gcc -mmcu=msp430x149 -mIAR -o p2a-reva -O p2a-reva.c fpga_IO.c
serial_IO.c
I get code generated such that functions in the fpga_IO.c (second) file
has mov r14 and mov r15 instructions instead of push instructions before
the call to uprintf(). Functions in the first file still have the
correct push instructions prior to the call to uprintf().
The following are the generated assembler code fragments:
Call to function uprintf( txChar, "done\n\r"); from function in source
file fpga_IO.c
26d4: 3e 40 ae 26 mov #9902, r14 ; #0x26ae
26d8: 3f 40 46 27 mov #10054, r15 ; #0x2746
26dc: b0 12 24 34 call #13348 ; #0x3424
Call to function uprintf( txChar, "done\n\r"); from function in
source file p2a-reva.c
11a2: 30 12 61 11 push #4449 ; #0x1161
11a6: 30 12 46 27 push #10054 ; #0x2746
11aa: b0 12 24 34 call #13348 ; #0x3424
Note that address 0x2746 is the function txChar() that should be used by
uprintf(). Uprintf() is at address 0x3424. Both functions are calling
the exact same uprintf() routine but with a different set up before
calling. The code in the first function should use push instead of mov
before calling the uprint() function.
What am I doing wrong?
Thanks.
John L. Shanton III
Little Optics, Inc.