This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USART: use of printf();

Hello,

I'm working with the AT91RM9200 - the USART is already configurated and works but I don't know how I could use the printf-function for the usart.

Now I'm sending a character with this function - it works, but it's ver uncomfortable if I want to send one sentence or numbers...

char  a[11] = "Hallo Welt";
        for(int i=0; i<11; i++)
        {

                while( !(COM1->US_CSR  & AT91C_US_TXRDY) )
                     continue;
                COM1->US_THR = (a[i] & 0xFF);
        }

Is there a possibility to use the printf-function for the first USART / not the DEBUG-Unit at the AT91?

printf("Hello World\n");

best regards
Johannes

Parents
  • Is there nobody who could help me?

    Now I have only the startup file from Keil, a empty main-routine and a short retarget.c file - that's all...

    #include <stdio.h>
    #include <rt_misc.h>
    
    #pragma import(__use_no_semihosting_swi)
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    
    void _sys_exit(int return_code) {
    label:  goto label;  /* endless loop */
    }
    

    error messages:

    compiling Retarget.c...
    Retarget.c(19): warning: #2681-D: name linkage conflicts with previous declaration of variable "std::__stdout" (declared at line 87 of "D:\Keil\ARM\RV31\INC\stdio.h")
    Retarget.c(19): error: #70: incomplete type is not allowed
    Retarget.c(20): warning: #2681-D: name linkage conflicts with previous declaration of variable "std::__stdin" (declared at line 87 of "D:\Keil\ARM\RV31\INC\stdio.h")
    Retarget.c(20): error: #70: incomplete type is not allowed
    Retarget.c(23): error: #734: function "fputc(int, std::FILE *)" conflicts with using-declaration of function "std::fputc(int, std::FILE *) C"
    Retarget.c(47): error: #734: function "ferror(std::FILE *)" conflicts with using-declaration of function "std::ferror(std::FILE *) C"
    Retarget.c - 4 Error(s), 2 Warning(s).

    Johannes

Reply
  • Is there nobody who could help me?

    Now I have only the startup file from Keil, a empty main-routine and a short retarget.c file - that's all...

    #include <stdio.h>
    #include <rt_misc.h>
    
    #pragma import(__use_no_semihosting_swi)
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    
    void _sys_exit(int return_code) {
    label:  goto label;  /* endless loop */
    }
    

    error messages:

    compiling Retarget.c...
    Retarget.c(19): warning: #2681-D: name linkage conflicts with previous declaration of variable "std::__stdout" (declared at line 87 of "D:\Keil\ARM\RV31\INC\stdio.h")
    Retarget.c(19): error: #70: incomplete type is not allowed
    Retarget.c(20): warning: #2681-D: name linkage conflicts with previous declaration of variable "std::__stdin" (declared at line 87 of "D:\Keil\ARM\RV31\INC\stdio.h")
    Retarget.c(20): error: #70: incomplete type is not allowed
    Retarget.c(23): error: #734: function "fputc(int, std::FILE *)" conflicts with using-declaration of function "std::fputc(int, std::FILE *) C"
    Retarget.c(47): error: #734: function "ferror(std::FILE *)" conflicts with using-declaration of function "std::ferror(std::FILE *) C"
    Retarget.c - 4 Error(s), 2 Warning(s).

    Johannes

Children
No data