[En-Nut-Discussion] Multiple UART support

zonedar sholder at summitsemi.com
Tue Sep 21 21:32:12 CEST 2010


Thanks for the tips Ulrich.

I tried what you said and it wasn't giving me any happiness.

I decide to take a step back and comment out the DEV_DEBUG code and assign
UART0 to stdout.  I'm still not getting anything out of the that UART.  So
either I have something configured wrong in NUTOS or something's wired
wrong.

Here's what I did:

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

    nr = NutRegisterDevice(&DEV_UART0, 0, 0);
    freopen(DEV_UART0_NAME, "w", stdout);
    _ioctl(_fileno(stdout), UART_SETSPEED, &baud);

   printf("here2\n");

Still looking at it...


uprinz wrote:
> 
> Hi Steve,
> 
> for me it is exactly sa easy as this:
>  >      nr = NutRegisterDevice(&DEV_DEBUG, 0, 0);
>  >      freopen(DEV_DEBUG_NAME, "w", stdout);
>  >      _ioctl(_fileno(stdout), UART_SETSPEED,&baud);
> 
> for another uart just repeat that
> 
> /* don't forget this one:*/
> FILE *uart0;
> FILE *uart1;
> 
> rc = NutRegisterDevice( &DEV_USART0, 0, 0);
> if( rc)
>    something failed;
> freopen(DEV_UART0.dev_name, "w", uart0);
> _ioctl(_fileno(uart0), UART_SETSPEED,&baud);
> 
> rc = NutRegisterDevice( &DEV_USART1, 0, 0);
> if( rc)
>    something failed;
> freopen(DEV_UART1.dev_name, "w", uart1);
> _ioctl(_fileno(uart1), UART_SETSPEED,&baud);
> 
> In my stm32 port I use 3 or more UARTs in this way.
> I haven't checked, if console is a reserved word by the libc or Nut/OS.
> 
> But you can put it another way:
> Assign the debug to stderr and on of the other UARTs to stdout ( and 
> stdin, if you use "r+" instead of "w"). You can reassign to by just do:
> stdout = stdin = uart0;
> 
> Now printf() goes to uart0 while stderr still goes to dbgu and 12 points 
> go to... ups :)
> 
> Ah, have a look into the uart example code. It just works fine.
> 
> Regards
> Ulrich
> 
> Am 21.09.2010 18:15, schrieb zonedar:
>>
>> 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.
>>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
> 
> 

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




More information about the En-Nut-Discussion mailing list