- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
G'day,
Just ran into a problem setting the baud rate by software under Nios2 v1.01. My apologies if this has already been posted before. Setup as follows: Optional Hardware Feature: uart divisor register Optional Compiler Flag: -DALTERA_AVALON_UART_USE_IOCTL#include "sys/termios.h"# include "sys/ioctl.h"
struct termios uart_settings;
// default baud rate set to 115200
ioctl(fd, TIOCMGET, &uart_settings);
uart_settings.c_ispeed = 57600;
uart_settings.c_ospeed = 57600; // Must set both c_ispeed & c_ospeed otherwise TIOCMGET fails.
ioctl(fd, TIOCMSET, &uart_settings);
The above code doesn't successfully change the baud rate. The problem is in the "altera_avalon_uart.c" function alt_avalon_uart_tiocmset(). Instead of calculating the new divisor value based on the new baud rate it uses the old baud rate. Also changed the divisor calc in accordance with the Nios 2 Processor Reference Manual Section 10-5, which matches what the SOPC buider generates. Change line... IOWR_ALTERA_AVALON_UART_DIVISOR(dev->base, ((dev->freq/speed) - 1));
...to... IOWR_ALTERA_AVALON_UART_DIVISOR(dev->base, ((dev->freq/dev->termios.c_ispeed) + 0.5));
ciao -- Bob
Link Copied
0 Replies
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