- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the readme.txt of the board_diag show that:
* - UART test * Tests UART functionality for the UART defined as STDOUT. * * Currently, only tested on the JTAG UART device. the component UART in the SOPC Builder has a option "Baud rate can be change by software". Are there any API that can control the divisor register and set baud rate with software? thank u!Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ffone13,
There is an ioctl call to set the baud rate etc for the UART. If you look in the manual for the UART n2cpu_nii51010.pdf and look under the software programming model there is a section in here on ioctl which is where you should start.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello rugbybloke,
could you look at the following code that change the baudrate? in the sopc builder i have set the option that divisor can be change. and the result is when execute: if (fd->dev->ioctl) { rc = fd->dev->ioctl(fd, req, arg); } it stop! /********************************************************/ int main (void) { char* msg = "hello world"; FILE* fp; struct termios* term; fp = fopen ("/dev/uart1", "w"); if (fp) { term->c_ispeed=B57600; ioctl(fp, TIOCMSET, term); fprintf(fp, "%s",msg); fclose (fp); } return 0; } /********************************************************/ could you show me how to do? thank you!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ffone13,
My guess is that you don't have the ioctl code included, the comment at the top of the driver gives you some clues /* * To reduce the code footprint of this driver, the ioctl() function is not * included by default. If you wish to use the ioctl features provided * below, you can do so by adding the option : -DALTERA_AVALON_UART_USE_IOCTL * to CPPFLAGS in the Makefile (or through the Eclipse IDE). */ If this does not solve the problem then either step into the ioctl call to find the offending line, or set a breakpoint in the ioctl code inside the UART driver to find where the problem is.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you are right.I have finished it. but i find a bug that it seems to be in "static int alt_avalon_uart_tiocmset (alt_avalon_uart_dev* dev, struct termios* term) " function
of the altera_avalon_uart.c . IOWR_ALTERA_AVALON_UART_DIVISOR(dev->base, ((dev->freq/speed) - 1)); the speed should be dev->termios.c_ispeed, i think. because firstly speed = dev->termios.c_ispeed; is the original value. thank you for reply!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ffone,
Looks like you're right thanks for the tip
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page