Altera_Forum
Honored Contributor
20 years agoDSP 2S60 NIOSII with uCOS II, using RS232
I am using DSP 2S60 NIOSII with uCOS, try to connect to PC-COM with RS232.
At PC side, I want to use windows Hyper Terminal. I got a testing program from Fischer and modified it as bellow: # include <stdio.h># include <string.h># include <unistd.h># include <fcntl.h># include "system.h" int main (int argc, char* argv[]) { int res, rx_count = 0, i; unsigned char rx_buf[100], test[30]; int fd; //open handler if((fd = open(UART1_NAME, O_RDWR | O_NONBLOCK)) < 0) { printf("Can not open %s \n", UART1_NAME); return(0); } printf("Please input any words\n"); while(1) { res = read(fd, test, 25); if(res > 0) { for(i = 0; i < res; i ++) { if(test == '\r') {rx_buf[rx_count] = 0;
//print out one line
printf("rx:count:%d:<%s>\n", rx_count, rx_buf);
rx_count = 0;
} else
rx_buf[rx_count ++] = test; } } } } After running it on 2S60, I can see message "Please input any words" on IDE's console, or see it on the shell window if I use nios2-terminal. But never can read any word from PC side. If I open HyperTerminal, can not see any message output on it and 2S60 also can not read any word from it. Does any one can help me to fix it. Thank you very much. David