Forum Discussion
Altera_Forum
Honored Contributor
20 years agoNIOS Uart : change baud rate
I am having trouble to change the baud rate of a NIOS avalon uart. Note that I am not running against any OS, just the "standard" native NIOS environment. I tried : alt_avalon_uart_ioc...
Altera_Forum
Honored Contributor
20 years agoThanks very much for the precise response.
It works. I wasn't aware of the ALTERA_AVALON_UART_USE_IOCTL. Cheers, -- Richard -- --- Quote Start --- originally posted by vlorenzo@Jan 14 2006, 11:05 AM for being able of modifying the uart baudrate, check theese:
- in sopcbuilder open the editor dialog for the uart component in your system (double click on it), there is a parametter for including an uart bauderate register;
- make sure that you're not using the reduced footprint driver's hal mode in your system library;
- include this define altera_avalon_uart_use_ioctl in the compiler preprocessor configuration settings for your system library and recompile it;
- add the includes# include <sys/ioctl.h> and# include <sys/termios.h> to your source file;
now you can use code like this for changing the uart speed:
struct termios termios;
int res = ioctl( uartfd, tiocmget, &termios );
termios.c_ispeed = your_new_bauderate;
termios.c_ospeed = your_new_bauderate;
res = ioctl( uartfd, tiocmset, &termios );
the above code can be used provided that you opened the uart using code like:
int uartfd;
uartfd = open( your_uart_device_name, o_rdwr | o_nonblock | o_noctty );
if (uartfd == -1)
{
printf( "fatal error with uart \"%s\"\r\n", uart_name );
return 1;
}
the options are ored according to my needs, which could be a little bit different from yours.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=12196)
--- quote end ---
--- Quote End ---