[En-Nut-Discussion] Multiple UART support

zonedar sholder at summitsemi.com
Tue Sep 21 18:15:07 CEST 2010


Hi,

  We're using a AT91SAM7X256-EK in a product.  Currently we have the
DEV_DEBUG working and assigned to stdio.  Getting lots of useful debug
messages out to a terminal.  

  We'd like to enable a second UART (UART0) to allow us to communicate to an
internal peripheral.  In the processes of bringing it up I was just going to
try and set it up similar and have it also send stuff to a terminal.  It
doesn't seem to be that easy.

  Here is the code:

   //
    nr = NutRegisterDevice(&DEV_DEBUG, 0, 0);
    freopen(DEV_DEBUG_NAME, "w", stdout);
    _ioctl(_fileno(stdout), UART_SETSPEED, &baud);

    printf("\n\nLG Debug Code - Nut/OS %s -- Compiled: %s %s --\n",
NutVersionString(), __DATE__, __TIME__);
    printf("DEV_DEBUG nr = %d\n", nr);


    nr = NutRegisterDevice(&DEV_UART0, 0, 0);
    printf("DEV_UART0 nr = %d\n", nr);
    console = fopen(DEV_UART0_NAME, "w");
    printf("here1\n");
    printf("console is %s\n",console ? "NOT NULL" : "NULL");
    //freopen(DEV_UART0_NAME, "w", console);
    _ioctl(_fileno(console), UART_SETSPEED, &baud);
    printf("here2\n");

    fprintf(console, "Hello world!\n");
    //fputs("Hello world!", console);
    //fflush(console);


  and here is the output from the Debug UART:

8:54:17.578> LG Debug Code - Nut/OS 4.8.3.0 -- Compiled: Sep 21 2010
08:43:31 --
8:54:17.578> DEV_DEBUG nr = 0
8:54:17.578> DEV_UART0 nr = 0
8:54:17.578> here1
8:54:17.578> console is NOT NULL
8:54:17.578> here2
8:54:17.578> 

  However I'm not gettgin anything from the fprintf on DEV_UART0 (terminal
connected to it's physical header).

  I'm certain it's something simple, but it's burned a day and I'm not
getting anywhere.  

  One thing that concerns me is that in board.h both DEV_DEBUG_NAME and
DEV_UART0_NAME are the same string.  Is this correct?

#ifndef DEV_DEBUG
#define DEV_DEBUG       devDebug0
#endif
#ifndef DEV_DEBUG_NAME
#define DEV_DEBUG_NAME  "uart0"
[...]
#ifndef DEV_UART0
#define DEV_UART0       devUart0
#endif
#ifndef DEV_UART0_NAME
#define DEV_UART0_NAME  "uart0"
#endif

Thanks!

  -Steve

-- 
View this message in context: http://old.nabble.com/Multiple-UART-support-tp29771050p29771050.html
Sent from the MicroControllers - Ethernut mailing list archive at Nabble.com.




More information about the En-Nut-Discussion mailing list