[En-Nut-Discussion] Help: UART1 problem
Harald Kipp
harald.kipp at egnite.de
Sun Nov 30 18:55:35 CET 2003
>
>/* define UART1 */
>NutRegisterDevice(&devUart1, 1, 0);
>uart1 = NutDeviceOpen("uart1");
>NutDeviceIOCtl(uart1, UART_SETSPEED, &rs485baud);
>
>// Testprint
>NutPrintString_P(uart1, PSTR("Test String"));
>NutPrintFlush(uart1);
This should still work, but using NutPrint is deprecated.
Better use standard I/O functions, like:
FILE *uart1;
u_long baud = 9600;
NutRegisterDevice(&devUart1, 0, 0);
uart1 = fopen("uart1", "r+");
_ioctl(_fileno(uart1), UART_SETSPEED, &baud);
fprintf(uart1, "Test String\n");
Note, that Ethernut 2 uses half duplex RS485. There is
currently no specific driver. In order to use the standard
UART driver, you need to explicitely switch the direction
bit, PD4 or PD5, depending on your setting of JP2.
To avoid long delays while switching directions, you may
use a modified uartavr.c. Switch to receive (PD4/5 output low),
when the TxComplete interrupt occurs and the tx buffer is empty.
Switch to transmit, before transmitting the first character.
Or simply wait until I finished the new USART driver.
Harald
More information about the En-Nut-Discussion
mailing list