Altera_Forum
Honored Contributor
16 years agoRS232 interface, DE2-70 board
Can someone please help me? I have two weeks left in my senior design project and have to interface a Doran 2200 Scale to an Altera DE2-70 board using RS232. I have the configuration set-up on the board and have the scale transmitting data to the board (I know this based off the blinking LED that is telling me data is being received). I am using C code to run on a softcore processor that I have put in the FPGA and need to read data from the RS232 port. I have this code written so far;
Insert Code: void get_weight_from_uart(char * weight){ FILE* fp; char in_char = 0; int pointer = 0; fp = fopen ("/dev/RS232", "r+"); //Open file for reading and writing if (fp ==0) { printf("error"); } if (fp) { while (1) { in_char = fgetc(fp); // Get a character from the UART. // if ((in_char == '\n') | (in_char == '\r') | (in_char == 0)) // { // fclose (fp); // return; // } // else // { weight[pointer++] = in_char; printf("0%0x\n",weight); delay(1000); // } } fclose (fp); } // return 0;} However when I read the data from those ports, I get the same thing printing over and over again which is; 05ffffa8 I am not sure whether or not I have the correct code written or why I am getting the same thing. Please advise. Thanks. Duffbuster