Forum Discussion
Altera_Forum
Honored Contributor
20 years agohow could i change my UART baud
My UART baud has been sent to 115200 in the SOPC builder, and can be changed by software,but hou could i chang it to be 9600 with the Language of Nios2,who can help me ,thanks very much!
Altera_Forum
Honored Contributor
20 years agosomething like this:
int uart_set_baudrate(int filedescriptor,int baudrate) { struct termios term; int res; assert(filedescriptor); res=ioctl(filedescriptor,TIOCMGET,&term); if(res<0) { DPRINTF("ERROR ioctl filedescriptor:%d\r\n",filedescriptor); return res; } term.c_ispeed=baudrate; term.c_ospeed=baudrate; res=ioctl(filedescriptor,TIOCMSET,&term); if(res<0) { DPRINTF("ERROR ioctl filedescriptor:%d\r\n",filedescriptor); } return res; } to get filedescriptor use: int fd; fd=open("/dev/uart_0",O_RDWR | O_NONBLOCK | O_NOCTTY);