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
  • There are many name linkage conflicts with previous declaration of variable "std::__stdin" (declared in stdio.h)

    FILE __stdout; (incomplete type is not allowed)

    I take a look into one example from keil - but I don't see the differences between these two projects

    my code in the retarget.c is

    #include <stdio.h>
    //#include <time.h>
    #include <rt_misc.h>
    
    #pragma import(__use_no_semihosting_swi)
    
    
    extern int  COM1_putchar(int ch);
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    
    int fputc(int ch, FILE *f) {
    
            volatile unsigned int i;
    
            while (COM1_putchar (ch) != 0) {
            for (i=0; i<1000; i++) {
                    /*** DO NOTHING ***/
            }
            }
            return (ch);
    }
    

    it's the same as in the example from keil - only to test it.

    best regards
    Johannes

Reply
  • There are many name linkage conflicts with previous declaration of variable "std::__stdin" (declared in stdio.h)

    FILE __stdout; (incomplete type is not allowed)

    I take a look into one example from keil - but I don't see the differences between these two projects

    my code in the retarget.c is

    #include <stdio.h>
    //#include <time.h>
    #include <rt_misc.h>
    
    #pragma import(__use_no_semihosting_swi)
    
    
    extern int  COM1_putchar(int ch);
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    
    int fputc(int ch, FILE *f) {
    
            volatile unsigned int i;
    
            while (COM1_putchar (ch) != 0) {
            for (i=0; i<1000; i++) {
                    /*** DO NOTHING ***/
            }
            }
            return (ch);
    }
    

    it's the same as in the example from keil - only to test it.

    best regards
    Johannes

Children
No data