[En-Nut-Discussion] Connecting Ethernut 1.3 with ATMega32 via UART

Ulrich Prinz uprinz2 at netscape.net
Sun Mar 14 20:43:03 CET 2010


Hi!

> A look at the datasheets of ATmega32 and ATmega128, which is
> actually the microcontroller used in Ethernut 1.3, tells me that both
> operates at a voltage of 4.5 - 5-5V.

AVR can operate from 1.8V to 5V. 5.5V is more an absolute-maximum.
But what I said before was not to meant to look for the operating
voltage the controllers can work in, but the one they are working at in
your application.

Easy said: You must ensure that both boards you connect, work at the
same voltage level. If they are powered from different supplies or
batteries, the pins interfacing between the boards may not differ more
then 0.5V.

If there might be differences between the voltage levels, keep the
connection as short as possible and put in a serial resistor with some
22...100R. This will reduce the current the higher voltage system will
induct into the lower ones, so it will avoid a latchup effect.

If you have both controllers on the same board and the same supply,
there is no problem at all.

> So, under these circumstances, can I directly connect the RxD of one
> chip to the TxD of the other chip and vice versa?

Yes.

> And one more question: ATmega128 has two UARTs: PE0 + PE1, and PD2 +
> PD3. Are PE0 + PE1 uart0? Is uart0 the UART, which is already used
> by Ethernut for the RS232-Port for the communication with the PC? And
> if I want to use uart1, so PD2 + PD3, how do I tell this
> NutRegisterDevice()?
>
I don't know as I use Nut/OS for AT91SAM7 and up. But they are named in 
the datasheet. Take a closer look. USART0 is always the one that is used 
by Nut/OS for debug communication by default. You can configure that 
through the configurator.

With SAM and AVR32 you need to assign the special function to the pin, 
but not with AVR. Simply use the USART with the Nut/OS functions.

So set it up like this:

     NutRegisterDevice(&DEV_UART0, 0, 0);
     freopen(DEV_DEBUG_NAME, "w", stdout);

DEV_UART0 is a define for devUsartAvr0. So DEV_UART1 will be the one you 
need to start.

Best regards, Ulrich



More information about the En-Nut-Discussion mailing list