Hi All,
P2040 do support 4 UARTs. Out of 4 i'm using two, UART0 and UART1.
Both UARTs are working as a console dev in standalone case.
by changing followings,
1) RCW value.
2) CONFIG_CONS_INDEX 1 or 2 in the /include/configs/P2041RDB.h file in the u-boot source.
3) root=/dev/ram rw console=ttyS0,115200 or root=/dev/ram rw console=ttyS1,115200
Till here everything is fine.
But when i tried to make UART1 as a console and UART0 just to send/receive normal data, UART1 is working properly while no transaction in UART0.
Wrote a small application for sending data in UART0,
appl:
char data[] = "aa";
int fd, i;
fd = open("/dev/ttyS0", O_RDWR);
if(fd <0)
printf("Error\n");
else
printf("Success\n");
for (i=0; i<10; i++){
write(data, sizeof(data), 1, fd);
}
Expected data on UART0 terminal(rs-232), But not coming.
Would be very thankful if someone help me out.
regards,
Gourav
Use termios API.
Look at the following examples for using console as serial port under Linux:
https://stackoverflow.com/questions/6947413/how-to-open-read-and-write-from-serial-port-in-c
https://www.tldp.org/HOWTO/pdf/Serial-Programming-HOWTO.pdf
http://man7.org/linux/man-pages/man3/termios.3.html
https://en.wikibooks.org/wiki/Serial_Programming/Serial_Linux
https://control.com/thread/1026196999
and drfaw attention on the following page for serial port locking:
https://blog.mbedded.ninja/programming/operating-systems/linux/linux-serial-ports-using-c-cpp/
Have a great day,
Pavel Chubakov
It looks like that your standalone application uses UART0 and UART1 from DUART1. The UART0 and UART1 use the same Internal Interrupt Number. Check your interrupt procedure.
See the Table 24-1 of the P2040 Reference Manual.
See simple program example for DUART in the attached file. It is code for the MPC8548. Similar code can be used on the P2040.
Have a great day,
Pavel Chubakov
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Pavel,
Thanks for your attention on my query.
Yes. Application does use UART0 and console dev prints are in UART1, with same interrupt.
Why should i go for DUART2??
My application prints are not reflecting on UART0.
regards,
Gourav