[En-Nut-Discussion] Problem on Using AT91SAM7X256 RS485 with Nut/OS
Mingshu Wang
mwang at ccontrols.com
Mon Jul 9 22:27:52 CEST 2007
Hi there,
I run into some problem when using RS485 on AT91SAM7X256 with Nut/OS. USART0 is connected to RS485 transceiver. I can transmit packets but I can't receive anything.
I also made a version without Nut/OS which seems working fine.
The code that inializes the USART is as below.
FILE *rs485;
unsigned long mstpbaudrate = 9600;
//Register our devices.
NutRegisterDevice(&DEV_UART, 0, 0);
rs485 = fopen(DEV_UART0_NAME, "rb+");//open in read/write binary mode
outr(USART0_BASE + US_MR_OFF, AT91C_US_PAR_NONE | AT91C_US_CHMODE_NORMAL | AT91C_US_CHRL_8_BITS | AT91C_US_USMODE_RS485);
_ioctl(_fileno(rs485), UART_SETSPEED, &mstpbaudrate);
Later I set the USART port into RS485 mode in the OS (function At91UsartInit() at \nut\arch\arm\dev\usartat91.c) instead of the application. I rebuild the OS but I still can NOT get the receiving work. Do I miss something?
/* Set UART mode to 8 data bits, no parity and 1 stop bit. */
outr(USARTn_BASE + US_MR_OFF, US_CHMODE_NORMAL | US_CHRL_8 | US_PAR_NO | US_NBSTOP_1 | 0x1);
Thanks for any help,
Mingshu
More information about the En-Nut-Discussion
mailing list