This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/AM5728: variable argument in C66x DSP

Part Number: AM5728

Tool/software: TI C/C++ Compiler

Dear Champs,

My customer is trying to test 'variable argument' in the C66x DSP code as below.

~~~~~~~~~

#include "stdint.h"

#include <stdarg.h>

 

void my_printf( const char *szFormat, ...)

{

    va_list  vaArgs;

    va_start(vaArgs, szFormat);

 

    UART_printf( szFormat, vaArgs );

 

    va_end(vaArgs);

}

 

char cT1Char = 'A';

char szT1Str[20] = "HIJKLMN";

uint32_t nT1Int = 256;

 

 

void xstdio_t1( UArg arg0, UArg arg1 )

{

    UART_printf("=======================\n\n");

    UART_printf("Test Uart\n");

    UART_printf("i: %d\n", nT1Int);

   UART_printf("c: %c\n", cT1Char);

    UART_printf("s: %s\n", szT1Str);

    UART_printf("i: %d c: %c s: %s\n", nT1Int, cT1Char, szT1Str);

    UART_printf("-----------------------\n\n");

 

    my_printf("Test my\n");

    my _printf("i: %d\n", nT1Int);

    my _printf("c: %c\n", cT1Char);

    my _printf("s: %s\n", szT1Str);

    my _printf("i: %d c: %c s: %s\n", nT1Int, cT1Char, szT1Str);

    UART_printf("-----------------------\n\n");

 

    UART_printf("Test Uart\n");

    UART_printf("i: %d\n", nT1Int);

    UART_printf("c: %c\n", cT1Char);

    UART_printf("s: %s\n", szT1Str);

    UART_printf("i: %d c: %c s: %s\n", nT1Int, cT1Char, szT1Str);

    UART_printf("-----------------------\n\n");

}

~~~~~~~~~

The result is as below.

~~~~~~~~~

Test Uart

i: 256

c: A

s: HIJKLMN

i: 256 c: A s: HIJKLMN

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

 

Test my

i: 5

c:

s: ?

i: 5 c:  s: 챱

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

 

Test Uart

i: 256

c: A

s: HIJKLMN

i: 256 c: A s: HIJKLMN

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

~~~~~~~~~

Could you please let me know what is the issue and how they can resolve this issue in C66x DSP?

Actually, I found below e2e and I thought this was calling convention issue and suggested to use below.

CCS/AM6548: Issue GCC v7.2.1 aarch64 using varargs for AM65xx - Processors forum - Processors - TI E2E...

e2e.ti.com
Part Number: AM6548 Tool/software: Code Composer Studio I post this issue in this forum because I don't know where else to post, sorry. --- I have a AM6548

use

UART_printf(szFormat, va_arg(vaArgs, int) );

instead of 

UART_printf( szFormat, vaArgs );

in above code.

But, even when use 'va_arg()' macro, they are still facing issue and the result is as below.

~~~~~~~~~~~

Test my

i: 1

c:

s:

i: 1 c:

         s: 챪r

~~~~~~~~~~~

Please help on this.

Their SW is pdk1.0.17 as below.

  - PDK :  pdk_am57xx_1_0_17

  - NDK : 3.61.1.01

  - SYS/BIOS : 6.76.3.01.

The C6000 compiler used is TI compiler v8.3.7.

Thanks and Best Regards,

SI.

  • I apologize for the delay.

    Please search the internet and learn about the standard RTS function vprintf.  Understand how it is different from printf.  

    This ...

    void my_printf( const char *szFormat, ...)

    ... cannot directly call UART_printf.  Instead, it should call a function that is similar to vprintf, but works on UART.  I do not know if such a function is available.

    Thanks and regards,

    -George